#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t, n, pre, ans, mod = 1000000007, tmp;
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
scanf("%d", &tmp);
for (int i = 1; i < n; ++i) {
pre = tmp;
scanf("%d", &tmp);
tmp = (ll(pre + 1) * tmp + pre) % mod;
}
cout << tmp << endl;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CmludCB0LCBuLCBwcmUsIGFucywgbW9kID0gMTAwMDAwMDAwNywgdG1wOwoKaW50IG1haW4oKSB7CglzY2FuZigiJWQiLCAmdCk7Cgl3aGlsZSAodC0tKSB7CgkJc2NhbmYoIiVkIiwgJm4pOwoJCXNjYW5mKCIlZCIsICZ0bXApOwoJCWZvciAoaW50IGkgPSAxOyBpIDwgbjsgKytpKSB7CgkJCXByZSA9IHRtcDsKCQkJc2NhbmYoIiVkIiwgJnRtcCk7CgkJCXRtcCA9IChsbChwcmUgKyAxKSAqIHRtcCArIHByZSkgJSBtb2Q7CgkJfQoJCWNvdXQgPDwgdG1wIDw8IGVuZGw7Cgl9CglyZXR1cm4gMDsKfQ==