P = 10 ** 9 + 7

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

b = [[0 for j in range(60)] for i in range(n)]

str_a = format(a[0], "0b")
l = len(str_a)
for i in range(len(str_a)):
  a_bit = int(str_a[l - 1 - i])
  b[0][i] = a_bit

for i in range(1, n):
  str_a = format(a[i], "0b")
  l = len(str_a)
  for j in range(l):
    a_bit = int(str_a[l - 1 - j])
    b[i][j] = b[i - 1][j] + a_bit
    
ans = 0
for i in range(1, n):
  str_a = format(a[i], "0b")
  l = len(str_a)
  for j in range(l):
    if str_a[j] == "0":
      ans = (ans + b[i - 1][l - 1 -j] * (2 ** (l - 1 - j))) % P
    else:
      ans = (ans + (i - b[i - 1][l - 1 - j]) * (2 ** (l - 1 - j))) % P

print(ans)