#include #include #include #include #include #include using namespace std; #define M 1000000007 typedef long long ll; int a[1005]; int d[1005]; int rev(int x) { return x <= 1 ? 1 : (ll)(M - M / x) * rev(M % x) % M; } int main() { ios::sync_with_stdio(false); int test; cin >> test; while(test--) { int n; cin >> n; int ans = 0; for(int i = 1; i <= n; ++i) { cin >> a[i]; d[i] = rev(a[i]); ans = (ans + a[i] / 2) % M; if(i == 1) continue; int tmp = (1 - (ll)(d[i - 1] - d[i] + M) % M * (a[i - 1] / 2) % M + M) % M; tmp = (ll)tmp * (a[i] / 2) % M; ans = (ans - tmp + M) % M; } cout << ans << '\n'; } return 0; }