n=int(eval(input()))

a=list(map(int,input().split()))

ans=0

mod=10**9+7

for j in range(60):

    cnt1=sum([1 for i in a if i>>j&1])

    cnt0=n-cnt1

    ans+=(cnt1*cnt0*2**j)

print((ans%(10**9+7)))

n=int(eval(input()))

a=list(map(int,input().split()))

s=0

for j in range(len(bin(max(a)))-2):

    cnt1=0

    cnt0=0

    for i in range(n):

      if (a[i]>>j)&1:

        cnt1+=1

      else:

        cnt0+=1

    s+=(cnt1*cnt0*2**j)%(10**9+7)

print((s%(10**9+7)))

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
for j in range(60):
    cnt1 = sum([1 for i in a if i >> j & 1])
    cnt0 = n - cnt1
    ans += cnt1 * cnt0 * 2**j
print((ans % (10**9 + 7)))

n = int(eval(input()))
a = list(map(int, input().split()))
s = 0
for j in range(len(bin(max(a))) - 2):
    cnt1 = 0
    cnt0 = 0
    for i in range(n):
        if (a[i] >> j) & 1:
            cnt1 += 1
        else:
            cnt0 += 1
    s += (cnt1 * cnt0 * 2**j) % (10**9 + 7)
print((s % (10**9 + 7)))

-ans = 0 -mod = 10**9 + 7 -for j in range(60): -    cnt1 = sum([1 for i in a if i >> j & 1]) -    cnt0 = n - cnt1 -    ans += cnt1 * cnt0 * 2**j -print((ans % (10**9 + 7))) +s = 0 +for j in range(len(bin(max(a))) - 2): +    cnt1 = 0 +    cnt0 = 0 +    for i in range(n): +        if (a[i] >> j) & 1: +            cnt1 += 1 +        else: +            cnt0 += 1 +    s += (cnt1 * cnt0 * 2**j) % (10**9 + 7) +print((s % (10**9 + 7)))