N = int(input())
As = [int(i) for i in input().split(" ")]

Nmax = len(format(max(As),"b"))

total = 0
for k in range(Nmax):
    
    counter = [0,0]
    
    for i in range(N):
        
        # k桁を取り出す
        ai_k = As[i] >> k & 1
        
        # 0と1の個数を数える
        counter[ai_k] += 1
    
    total += (2**k)*counter[0]*counter[1]
    
print(total%int(1e9+7))