import sys import itertools import math def S(): return sys.stdin.readline().rstrip() def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LS(): return list(sys.stdin.readline().rstrip().split()) t = I() MOD = 10**9+7 for _ in range(t): n = I() a = LI() ans = 1 for i in range(n): ans = (ans * (a[i]+1))%MOD ans = (ans-1)*pow(n, MOD-2, MOD) ans %= MOD print(ans)