#include #include #include #include #include #define LL __int64 #define mem(a,b) memset(a,b,sizeof(a)) #define MAX 500010 using namespace std; int n; int num[MAX]; int mod = 1000000007; int read() { int ret = 0; char ch; while((ch = getchar()) > '9' || ch < '0'); while(ch >= '0' && ch <='9') { ret = ret * 10 + ch - '0'; ch = getchar(); } return ret; } int main() { int t; scanf("%d",&t); while(t--) { scanf("%d",&n); LL ans = 0; LL sum = 0; for(int i = 0;i < n;i++) { num[i] = read(); sum = (LL)(n - i) * (i + 1); sum %= mod; ans += (LL)num[i] * sum; ans %= mod; } printf("%I64d\n",ans); } return 0; }