#include using namespace std; const int N=1000005,M=1000000007; int t,n,m,i,j,a[100005]; long long qpow(long long a,long long b) { long long s=a,ans=1; while(b) { if(b&1) ans=ans*s%M; s=s*s%M; b>>=1; } return ans; } int main(){ scanf("%d",&t); long long inv2=qpow(2,M-2); while(t--) { scanf("%d",&n); long long ans=0; for(i=1;i<=n;++i) { scanf("%d",&a[i]); if(i==1) ans+=a[i]/2; else ans+=(qpow(a[i-1],M-2)-qpow(a[i],M-2))%M*a[i]%M*a[i-1]%M*inv2%M*inv2%M; } cout<<(ans%M+M)%M<