#解説見た
#--------------------------------------------------
import strutils, sequtils, math, algorithm, tables, sets, lists, intsets, critbits, future
template `max=`(x,y) = x = max(x,y)
template `min=`(x,y) = x = min(x,y)
let read* = iterator: string {.closure.} =
    while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read().parseInt
const MOD = 10^9+7
proc toInt(c:char): int = int(c) - int('0')
#--------------------------------------------------
var n = scan()
var a = newSeqWith(n, scan())
var ans = 0
var bitlen = 61
var cnt = newSeq[int](bitlen)

for i in a:
    let bin = i.toBin(bitlen)
    for ind,j in bin:
        cnt[ind] += j.toInt


for i in a:
    let bin = i.toBin(bitlen)
    n -= 1
    for ind,j in bin:
        if j == '1': cnt[ind] -= 1
        let oneCnt = cnt[ind]
        let zeroCnt = n - oneCnt
        if j == '1':
            ans += 2^(bitlen-ind-1) * zeroCnt
        else:
            ans += 2^(bitlen-ind-1) * oneCnt
        ans = ans mod MOD

echo ans
#[
var cnt = newSeq[int]()
for i in a:
    var bin = i.toBin(64)
    for ind,j in bin:
        cnt[bin.len - ind - 1] += 1

]#