#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math

n = int(input())
a = [int(i) for i in input().split()]
bound = int(math.log2(max(a)) + 1)

k = [0] * bound

for i in a:
    for j in range(bound):
        if (i >> j) & 1:
            k[j] += 1

ans = 0
c = 0
for d in k:
    ans += (d * (n - d) * 2**c)  % (10**9 + 7)
    c += 1
    
print(ans % (10**9 + 7))