#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 100000, M = 1000000007;
int n, t, a[N], dp[N];
int calc(int i) {
if (i == n) return 1;
int &ret = dp[i];
if (ret != -1) return ret;
ret = calc(i + 1);
ret = (ret + (ll)a[i] * calc(i + 1)) % M;
return ret;
}
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
memset(dp, -1, sizeof dp);
printf("%d\n", calc(0) - 1);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnR5cGVkZWYgbG9uZyBsb25nIGxsOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgTiA9IDEwMDAwMCwgTSA9IDEwMDAwMDAwMDc7CmludCBuLCB0LCBhW05dLCBkcFtOXTsKCmludCBjYWxjKGludCBpKSB7CglpZiAoaSA9PSBuKSByZXR1cm4gMTsKCWludCAmcmV0ID0gZHBbaV07CglpZiAocmV0ICE9IC0xKSByZXR1cm4gcmV0OwoJcmV0ID0gY2FsYyhpICsgMSk7CglyZXQgPSAocmV0ICsgKGxsKWFbaV0gKiBjYWxjKGkgKyAxKSkgJSBNOwoJcmV0dXJuIHJldDsKfQoKaW50IG1haW4oKSB7CglzY2FuZigiJWQiLCAmdCk7Cgl3aGlsZSAodC0tKSB7CgkJc2NhbmYoIiVkIiwgJm4pOwoJCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQoJCQlzY2FuZigiJWQiLCAmYVtpXSk7CgkJbWVtc2V0KGRwLCAtMSwgc2l6ZW9mIGRwKTsKCQlwcmludGYoIiVkXG4iLCBjYWxjKDApIC0gMSk7Cgl9CglyZXR1cm4gMDsKfQ==