t = int(input()) def result(arr,n): if n > 61: return 0 charge = 0 x = 2**(n-1) for num in arr: if num >= x: charge = (charge+num) % 1000000007 return charge for case in range(t): n = int(input()) arr= map(int, input().split()) print(result(arr,n))