#include #include using namespace std; typedef long long ll; const ll mod=1e9+7; ll mypow(ll a,ll b){ ll ans=1; while(b) { if(b&1)ans=ans*a%mod; a=a*a%mod; b>>=1; } return ans; } ll n,a[15],T,ans=0; int main() { scanf("%lld",&T); while(T--) { ans=0; scanf("%lld",&n); for(int i=1;i<=n;i++)scanf("%lld",&a[i]),a[i]=a[i]/2; ans=a[1]; for(int i=2;i<=n;i++)ans=(ans+a[i]*a[i-1]%mod*(mypow(2*a[i-1],mod-2)-mypow(2*a[i],mod-2)+mod))%mod; printf("%lld\n",ans); } return 0; }