t = int(input()) for _ in range(t): n = int(input()) A = list(map(int, input().split())) mod = 10**9+7 c = 0 for a in A: c += c*a+a c %= mod print(c)