#include #define LL long long using namespace std; template void read(T &x){ x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();} while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();} x *= f; } inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); } const int P = 1e9 + 7; inline int power(int x,int y){ static int r; r=1; while (y){ if (y&1) r=(LL)r*x%P; x=(LL)x*x%P;y>>=1; } return r; } int n,a[11],ans; int solve(){ int i; read(n); for (i = 1; i <= n; ++i) read(a[i]); ans = a[1]/2; for (i = 2; i <= n; ++i){ int len1 = power(a[i-1]/2,P-2),len2 = power(a[i]/2,P-2); len1 = (LL)len1 * (a[i-1]/2) % P; len2 = (LL)len2 * (a[i-1]/2) % P; int prob = (LL)(len1-len2+P)%P * power(len1,P-2) % P * (P+1>>1) % P; ans = (ans + 1ll * prob * (a[i]/2) % P) % P; } cout << ans <<'\n'; return 0; } int main(){ int T;read(T); while (T--) solve(); }