#include #define fo(i,a,b) for(int i=a;i<=b;i++) #define fod(i,a,b) for(int i=a;i>=b;i--) #define me0(a) memset(a,0,sizeof(a)) #define me1(a) memset(a,-1,sizeof(a)) #define op freopen("in.txt", "r", stdin) #define pii pair #define mp(x,y) make_pair(x,y) using namespace std; const int INF = 0x3f3f3f3f; typedef unsigned long long ULL; typedef long long LL; void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; } const int mod=1e9+7; const int maxn=1e6+10; LL ksm(LL a,LL b){ LL res=1; while(b){ if(b&1) res = res*a%mod; a=a*a%mod;b>>=1; } return res; } int a[100]; int main(){ // op; int t;read(t); while(t--){ int n;read(n); read(a[1]); LL ans=0; ans=a[1]*ksm(2,mod-2)%mod; fo(i,2,n){ read(a[i]); ans+=(a[i]-a[i-1])*ksm(4,mod-2)%mod; ans%=mod; } printf("%lld\n",ans); } return 0; }