n = int(eval(input()))

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

mod = 10**9+7

ans = 0

for i in range(60):

  keta=1<<i

  cnt=0

  for j in a:

    if keta & j:

      cnt+=1

  ans+=((keta%mod)*cnt*(n-cnt))%mod





print((ans%mod))

import numpy as np



n = int(eval(input()))

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

mod = 10**9+7

ans = 0

a=np.array(a)



for i in range(60):

  keta = a>>i & 1

  num1 = int(keta.sum())

  num0 = n - num1

  ans+= ((2**i)%mod)*(num1*num0)

  ans%=mod

print(ans) 
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(60):
    keta = 1 << i
    cnt = 0
    for j in a:
        if keta & j:
            cnt += 1
    ans += ((keta % mod) * cnt * (n - cnt)) % mod
print((ans % mod))

import numpy as np

n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
a = np.array(a)
for i in range(60):
    keta = a >> i & 1
    num1 = int(keta.sum())
    num0 = n - num1
    ans += ((2**i) % mod) * (num1 * num0)
    ans %= mod
print(ans)

+import numpy as np + +a = np.array(a) -    keta = 1 << i -    cnt = 0 -    for j in a: -        if keta & j: -            cnt += 1 -    ans += ((keta % mod) * cnt * (n - cnt)) % mod -print((ans % mod)) +    keta = a >> i & 1 +    num1 = int(keta.sum()) +    num0 = n - num1 +    ans += ((2**i) % mod) * (num1 * num0) +    ans %= mod +print(ans)