P = 10 ** 9 + 7
 
n = int(input())
a = list(map(int, input().split()))
a.sort()
str_a = [format(a[i], "0b") for i in range(n)]

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