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