#include using namespace std; int main() { const int mod = 1000000007; int inv2 = (mod + 1) / 2; int inv4 = (mod + 1) / 4; int n, test; cin >> test; while (test--) { int n; cin >> n; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int ans = a[0] / 2; for (int i = 1; i < n; ++i) { ans = (ans + (a[i] - a[i - 1]) / 2ll * inv2) % mod; } printf("%d\n", ans); } }