N = int(input())
A = list(map(int,input().split()))

num_ones = [0]*60
powers_of_two = [pow(2,x,1000000007) for x in range(60)]

ans = 0
for i in range(N-1,-1,-1):
  for j in range(60):
    if A[i] & 1:
      ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
      num_ones[j] += 1
    else:
      ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
    A[i] >>= 1
print(ans)
