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