n = int(input())
a = [ int(x) for x in input().split()]

mx = max(a)
k= len(bin(mx))-2

a = [ f'{x:0>{k}b}'  for x in a]

#print(a)

total = 0
for i in range(k-1,-1,-1):
    ones = 0
    for j in range(n):
      	if(a[j][i]=='1'):
            ones+=1
           
    zeroes=n-ones
    #print(ones)
    total+= ones*zeroes*(2**(k-i-1))       
         
print(total%(10**9+7))
