n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7


def cal_xor(max_num, cnt, exp):
    return cnt * (max_num - cnt) * (2 ** exp)


dig = len(format(max(a), 'b'))
bi_digit_cnt = [0] * dig
for i in a:
    bi_i = format(i, 'b').zfill(dig)
    for j in range(len(bi_i)):
        if bi_i[-1-j] == '1':
            bi_digit_cnt[j] += 1

ans = 0

for i in range(dig):
    ans += cal_xor(n, bi_digit_cnt[i], i)
    ans %= MOD

print(ans)