#include using namespace std; #define MOD 1000000007 int test, n, ans, a[10]; long long power(long long x, int y) { long long ans = 1; while (y) { if (y & 1) ans = ans * x % MOD; x = x * x % MOD; y /= 2; } return ans; } int calc(int x, int y) { long long ans = 0; for (int i = 0; i < 2 * y; ++i) for (int j = 0; j < y; ++j) ans += (2 * j * x + x + i - 1) / (2 * y) - ((2 * j * x + i) / y - 1) / 2 - 1; return ans % MOD * power(2 * y, MOD - 2) % MOD; } int main() { scanf("%d", &test); while (test--) { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); a[i] /= 2; } ans = a[n - 1]; for (int i = n - 2; i >= 0; --i) ans = ((ans - calc(a[i + 1], a[i])) % MOD + MOD) % MOD; printf("%d\n", (ans + MOD - (n - 1)) % MOD); } return 0; }