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")
for i in range(len(str_a)):
  a_bit = int(str_a[-(i + 1)])
  b[0][i] = a_bit
 
for i in range(1, n):
  str_a = format(a[i], "0b")
  for j in range(len(str_a)):
    a_bit = int(str_a[-(j + 1)])
    b[i][j] = b[i - 1][j] + a_bit
    
ans = 0
for i in range(1, n):
  str_a = format(a[i], "0b")
  for j in range(len(str_a)):
    if str_a[-(j + 1)] == "0":
      ans += b[i - 1][j] * (2 ** j)
    else:
      ans += (i - b[i - 1][j]) * (2 ** j)
 
print(ans % P)