import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N = ii()
    A = lmis()
    maxA = max(A)
    ans = 0
    for i in count():
        b = 1<<i
        if b > maxA:
            break
        S1 = sum(bool(a & b) for a in A)
        S0 = N - S1
        ans += (S1*S0) * (b%N1097)
        ans %= N1097
    print(ans)

main()
