N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7
ans = 0

for i in range(60):
  B = [0]*N
  one = 0
  for j in range(N):
    B[j] = A[j]%pow(2,(i+1))//pow(2,i)
    one += B[j]
  zero = N - one
  ans += one*zero*pow(2,i)
  ans %= mod
  #print(one,zero)

print(ans)
