# -*- coding: utf-8 -*-
# D

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N = int(input())
a = list(map(int, input().split()))

max_len = len(bin(max(a))[2:])
l = [0] * max_len

for a in a:
    temp = bin(a)[2:][::-1]
    for i in range(len(temp)):
        l[i] += int(temp[i])

ans = 0
mod = 10**9 + 7

for i in range(max_len):
    ans += pow(2, i, mod) * l[i] * (N-l[i])

print(ans % mod)
