#include using namespace std; template using vec = vector; template using vvec = vec>; template using lqueue = priority_queue, greater>; template using gqueue = priority_queue, less>; int main() { constexpr int64_t mod = 1e9 + 7; auto op = [&](int64_t a, int64_t b) { return (a + b + a * b) % mod; }; int t; cin >> t; while (t--) { int n; cin >> n; int64_t ans = 0; for (int i = 0; i < n; ++i) { int a; cin >> a; ans = op(ans, a); } cout << ans << endl; } }