for _ in range(int(input())): input() ans = 0 for a in map(int, input().split()): ans += a + ans * a ans %= 10 ** 9 + 7 print(ans)