#include using namespace std; #define ll long long const ll mod =1e9+7; ll mypow(ll a,ll b){ ll ret=1; while(b){ if(b&1)ret=ret*a%mod; a=a*a%mod;b>>=1; } return ret; } int a[1010]; int main(){ ios::sync_with_stdio(0);cin.tie(0); int t;cin>>t; while(t--){ int n;cin>>n; int ans=0; for(int i=1;i<=n;i++)cin>>a[i],a[i]/=2,ans+=a[i]; cout<<(a[1]+a[n])*(mod+1)/2%mod<