import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import functools
import itertools
import math
INF = float('inf')
MOD = 10**9+7

M = 60
N = int(input())
A = [int(x) for x in input().split()]
f = [[0] * M for i in range(N+1)]
for i in range(N):
    a = A[i]
    for j in range(M):
        f[i+1][j] = f[i][j] + (a & 1)
        a >>= 1
ans = 0
for i in range(N):
    k = 1
    for j in range(M):
        if (A[i]>>j) & 1:
            ans += k * (N - i - 1 - f[N][j] + f[i+1][j])
        else:
            ans += k * (f[N][j] - f[i+1][j])
        ans %= MOD
        k <<= 1
        k %= MOD
print(ans)

