n=int(eval(input()))

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



mod=10**9+7



ans=0

for i in range(60):

  on=0

  off=0

  for j in a:

    if (j>>i)&1:

      on+=1

    else:

      off+=1

  ans+=(on*off)*(2**i)

  ans%=mod



print(ans)
import numpy as np



n=int(eval(input()))

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

mod=10**9+7



s=0

for i in range(60):

    bit = np.count_nonzero(a & 1)

    s += bit*(n-bit)*(2**i)

    a >>= 1

print((s % mod))
n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(60):
    on = 0
    off = 0
    for j in a:
        if (j >> i) & 1:
            on += 1
        else:
            off += 1
    ans += (on * off) * (2**i)
    ans %= mod
print(ans)

import numpy as np

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

+import numpy as np + -a = list(map(int, input().split())) +a = np.array(list(map(int, input().split()))) -ans = 0 +s = 0 -    on = 0 -    off = 0 -    for j in a: -        if (j >> i) & 1: -            on += 1 -        else: -            off += 1 -    ans += (on * off) * (2**i) -    ans %= mod -print(ans) +    bit = np.count_nonzero(a & 1) +    s += bit * (n - bit) * (2**i) +    a >>= 1 +print((s % mod))