MOD = 10 ** 9 + 7 for _ in range(int(input())): N = int(input()) A = list(map(int,input().split())) b = 0 for a in A: b = b + a + b * a b %= MOD print(b)