import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
A = list(map(int, input().split()))
A.sort()

ml = len(format(A[-1], 'b'))
bA = [list(map(int, list(format(val, '061b')))) for val in A]
#bAT = list(zip(*bA))
#bAT = bAT[::-1]
nbA = np.asarray(bA).sum(axis=0)[::-1]

cnt = 0
for i, val in enu(nbA):
    cnt += (N-val)*val*(2**(i))
    cnt %= MOD

print(cnt)

