mod = 10**9 + 7
t = int(input())

for _ in range(t):
    s = 0
    n = int(input())
    a = [int(v) for v in input().split()]
    for v in a:
        s = (s + v + s * v) % mod
    print(s)