import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
mod = 10 ** 9 + 7

#0埋め　桁合わせ
def digit(n, r):
    n = str(n)
    l = len(n)
    n = '0' * (r - l) + n
    return n

n = INT()
a = LIST()
arr = [0 for _ in range(61)]
arr2 = [0 for _ in range(61)]
for i in range(1, n + 1):
    bn = digit(bin(a[i - 1])[2:], 61)
    for j in range(61):
        arr[j] += int(bn[j])
for i in range(61):
    arr2[i] = n - arr[i]
    if arr2[i] == n:
        arr2[i] = 0
ans = 0
for i in range(61):
    ans *= 2
    ans += arr[i] * arr2[i]
    ans %= mod
print(ans)
