import numpy as np
n = int(input())
a = list(map(int,input().split()))
m = len(bin(max(a)))-2
b = np.array([0]*m)
ans = 0
for i in range(n):
  b += np.array([(a[i] >> j) & 1 for j in range(m)])
for i in range(m):
  ans += ((2**i)*b[i]*(n-b[i]))%(10**9+7)
print(ans%(10**9+7))