#include typedef long long LL; const int Mod = 1000000007; const int Inv4 = (Mod + 1) / 4; const int MN = 15; int N, S, x; int main() { int Tests; scanf("%d", &Tests); while (Tests--) { scanf("%d", &N), S = 0; for (int i = 1; i <= N; ++i) { scanf("%d", &x); if (i == 1) S += x; if (i == N) S += x; } printf("%lld\n", (LL)S * Inv4 % Mod); } return 0; }