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