def solve(): n = int(input()) a = list(map(int,input().split())) mod = 10**9 + 7 s = a[0] for i in range(1,n): s = s+a[i] + (s*a[i]) s %= mod print(s) t = int(input()) for _ in range(t): solve()