T = int(input()) for _ in range(T): N = int(input()) A = list(map(int, input().split())) MOD = 1e9 + 7 ans = 0 for i in range(N): p = A[i] for j in range(i + 1, N+1): ans = (ans + p) % MOD if j < N: p = p * A[j] % MOD print(ans)