#include #include #define mod 1000000007 using namespace std; int T,inv4,n,x,y,ans; typedef long long ll; int ksm(int x,int y) { int ans=1; while (y) { if (y&1) ans=(ll)ans*x%mod; x=(ll)x*x%mod; y>>=1; } return ans; } int main() { inv4=ksm(4,mod-2); scanf("%d",&T); while (T--) { scanf("%d",&n); scanf("%d",&x); ans=x/2; for (int i=2;i<=n;i++) { scanf("%d",&y); ans=(ans+(ll)(y-x)*inv4%mod)%mod; x=y; } printf("%d\n",ans); } }