#include using namespace std; #ifdef DEBUG #define display(x) cerr << #x << " = " << x << endl; #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define display(x) {} #define eprintf(...) do {} while(0) #endif template bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; } template bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; } template ostream& operator << (ostream& out, const vector &v) { int n = v.size(); out << "{"; for(int i = 0; i < n; ++i) { if(i) out << ", "; out << v[i]; } return out << "}"; } template ostream& operator << (ostream& out, const pair &v) { return out << "(" << v.first << ", " << v.second << ")"; } typedef long long LL; typedef pair pii; const int P = 1000000007; LL qpow(LL a, LL b) { LL r = 1; while(b) { if(b & 1) (r *= a) %= P; (a *= a) %= P; b >>= 1; } return r; } int qinv(LL x) { return qpow(x % P, P - 2); } const LL i2 = (1 + P) / 2; int expect(LL j, LL i) { // j <= i LL ii = qinv(i), ij = qinv(j); return (ij + ii) * j % P * i2 % P; } int solve() { int n; cin >> n; vector a(n); for(int i = 0; i < n; ++i) cin >> a[i]; LL sum = 0; for(int i = 0; i < n; ++i) sum += a[i] / 2; for(int i = 0; i + 1 < n; ++i) (sum -= (LL)expect(a[i], a[i + 1]) * (a[i + 1] / 2)) %= P; sum = (sum % P + P) % P; return sum; } int main() { #ifndef LOCAL ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #endif int T; cin >> T; while(T--) cout << solve() << endl; return 0; }