#include using namespace std; using ll = long long; const int mod = 1000000007; int main(){ int t; cin >> t; for(int i = 0; i < t; i++){ int n; cin >> n; vector a(n); for(int i = 0; i < n; i++) cin >> a[i]; ll ans = 1; for(int i = 0; i < n-1; i++){ ans = (a[i]*a[i+1] + a[i] + a[i+1])%mod; ans %= mod; ans = (ans+mod)%mod; a[i+1] = ans; } cout << ans << endl; } return 0; }