from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions

from decimal import Decimal

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



n = inp()

a = inpl()

a.sort()

lmx = len(bin(a[-1])) - 2

cnt = [[0,0] for _ in range(lmx)]

for i in a:

    for j in range(lmx):

        tt = 1 if (i>>j)&1 else 0

        cnt[j][tt] += 1



res = 0

for i,bit in enumerate(cnt):

    x,y = bit

    res += x*y*pow(2,i)

    res %= mod

print(res)
from collections import Counter,defaultdict,deque

from heapq import heappop,heappush

from bisect import bisect_left,bisect_right 

import sys,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



n = inp()

a = inpl()

ln = len(bin(max(a))) -2

cnt = [0] * ln

for x in a:

    for shift in range(ln):

        cnt[shift] += (x>>shift)%2

# print(cnt)

res = 0

for i in range(ln):

    now = cnt[i] * (n-cnt[i])

    res += now*pow(2,i)

    res %= mod

print(res)  



from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions
from decimal import Decimal

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


n = inp()
a = inpl()
a.sort()
lmx = len(bin(a[-1])) - 2
cnt = [[0, 0] for _ in range(lmx)]
for i in a:
    for j in range(lmx):
        tt = 1 if (i >> j) & 1 else 0
        cnt[j][tt] += 1
res = 0
for i, bit in enumerate(cnt):
    x, y = bit
    res += x * y * pow(2, i)
    res %= mod
print(res)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


n = inp()
a = inpl()
ln = len(bin(max(a))) - 2
cnt = [0] * ln
for x in a:
    for shift in range(ln):
        cnt[shift] += (x >> shift) % 2
# print(cnt)
res = 0
for i in range(ln):
    now = cnt[i] * (n - cnt[i])
    res += now * pow(2, i)
    res %= mod
print(res)

-from heapq import heappop, heappush, heapify -import sys, bisect, math, itertools, fractions -from decimal import Decimal +from heapq import heappop, heappush +from bisect import bisect_left, bisect_right +import sys, math, itertools, fractions, pprint -a.sort() -lmx = len(bin(a[-1])) - 2 -cnt = [[0, 0] for _ in range(lmx)] -for i in a: -    for j in range(lmx): -        tt = 1 if (i >> j) & 1 else 0 -        cnt[j][tt] += 1 +ln = len(bin(max(a))) - 2 +cnt = [0] * ln +for x in a: +    for shift in range(ln): +        cnt[shift] += (x >> shift) % 2 +# print(cnt) -for i, bit in enumerate(cnt): -    x, y = bit -    res += x * y * pow(2, i) +for i in range(ln): +    now = cnt[i] * (n - cnt[i]) +    res += now * pow(2, i)