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

dp = [[0 for i in range(61)] for i in range(n)]
for i in range(n):
  for j in range(61):
    if (a[i] >> j) & 1: dp[i][j] = 1


ans = 0
for j in range(61):
  cnt_0 = 0
  cnt_1 = 0
  cnt = 0
  for i in range(n):
    if dp[i][j] == 0:
      cnt += cnt_1
      cnt_0 += 1
    else:
      cnt += cnt_0
      cnt_1 += 1
    
  p = 2**j
  ans = (ans + cnt*p) % 1000000007

print(ans)