# An efficient Python3 program to compute 
# sum of bitwise OR of all pair 

# Returns sum of bitwise OR 
# of all pairs 
mod=1000000007
def sumXOR( arr, n): 
	
	sum = 0
	for i in range(0, 60): 

		# Count of zeros and ones 
		zc = 0
		oc = 0
		
		# Individual sum at each bit position 
		idsum = 0
		for j in range(0, n): 
			if (arr[j] % 2 == 0): 
				zc = zc + 1
				
			else: 
				oc = oc + 1
			arr[j] = int(arr[j] / 2) 
		
		
		# calculating individual bit sum 
		curr=(oc*zc)%mod
		idsum = (curr * ((1 << i)%mod))%mod
		# final sum	 
		sum = (sum + (idsum)%mod )%mod
	
	return sum%mod



# driver function 
sum = 0
n=int(input())
arr = list(map(int,input().split())) 
for i in range(n):
    arr[i]=arr[i]
sum = sumXOR(arr, n); 
print (sum) 

# This code is contributed by saloni1297 
