mod = pow(10,9) + 7 def calc(x, y): return x + y + x * y t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) ans = 0 for j in range(n): ans = calc(ans, a[j]) print(ans % mod)