#include using namespace std; const int mod = 1000000007; inline int qp(int a, int b) { int res = 1; while (b) { if (b & 1) res = 1ll * res * a % mod; a = 1ll * a * a % mod; b >>= 1; } return res; } int n, a[15], p[15]; int main() { int T; scanf("%d", &T); while (T--) { scanf("%d", &n); int res = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); res += a[i] / 2; } for (int i = 2; i <= n; i++) { res = (res - 1ll * qp(2 * a[i], mod - 2) * (a[i] + a[i - 1]) % mod * (a[i] / 2) % mod + mod) % mod; } printf("%d\n", res); } return 0; }