#include using namespace std; typedef long long ll; const ll p = 1e9 + 7; int a[20]; ll qpow(ll x, ll y) { ll res = 1; while(y) { if(y & 1) res = res * x % p; x = x * x % p; y >>= 1; } return res; } int main() { int t; scanf("%d", &t); ll inv4=qpow(4,p-2); while(t--) { int n, sum = 0; scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i]; ll y = sum/2, x = 0; for(int i = 1; i < n; i++) { x += a[i] * a[i + 1] * (qpow(a[i], p - 2) + qpow(a[i + 1], p - 2)) % p; x %= p; } cout <<(y-x*inv4%p+p)%p << endl; } }