
import heapq
import collections
import math
import sys
N =  int(input())
input = sys.stdin.readline
# num = a << b →  a  * (2 ** b)
# 1 << i → i桁目のマスク
# mask = 1 << i
# num = a << b
# num & mask
nums = list(map(int,input().split(" ")))
keta = [0] * 61
# ある桁の1の出現回数
# keta[k] → 2**k の桁
jijou = []
MOD = 10 ** 9 + 7
for i in range(62):
    temp = 1 << i
    temp%= MOD
    jijou.append(temp)

for num in nums:
    # s = format(num,"b")
    # l = len(s)

    for i in range(0,62):
        if num == 0:
            break
        temp = num & 1
        num  = num >> 1
        keta[i] += temp

ans = 0
for j,num in  enumerate(nums[:-1]):

    for i in range(0,61): #i →  2 ** i 乗 桁目に対応

        if num == 0:
            ans += (keta[i] * jijou[i]) % MOD
        else:
            temp = num & 1
            num = num >> 1
            if temp == 0:
                ans += (keta[i] * jijou[i]) % MOD
            else:
#              (N - j + 1) - (keta[i] + 1 ) → 0が経っているところの個数
                ans += (( (N - j + 1) - (keta[i] + 1)  ) * ( jijou[i]) ) % MOD
                keta[i] -= 1
        ans %= MOD
    ans %= MOD


print(ans)