import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") _print = lambda *x: print(*x, file=sys.stderr) t = int(input()) M = 10**9+7 def sub(a): n = len(a) dp = [0]*(n+1) dp[0] = 1 for i in range(n): ndp = [0]*(n+1) ndp[0] = 1 for j in range(1,n+1): ndp[j] = dp[j-1]*a[i] + dp[j] ndp[j] %= M dp = ndp # print(dp) ans = sum(dp[1:])%M return ans for _ in range(t): n = int(input()) a = list(map(int, input().split())) print(sub(a))