#include constexpr int P = 1000000007; int power(int a, int b) { int res = 1; for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) res = 1ll * res * a % P; return res; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; std::cin >> t; while (t--) { int n; std::cin >> n; std::vector a(n); for (int i = 0; i < n; ++i) std::cin >> a[i]; int ans = 0; for (int i = 0; i < n; ++i) ans += a[i] / 2; for (int i = 1; i < n; ++i) { int x = (power(a[i - 1], P - 2) + power(a[i], P - 2)) % P; ans = (ans + 1ll * (P - x) * a[i] / 2 * a[i - 1] / 2) % P; } std::cout << ans << "\n"; } return 0; }