from sys import stdin
import math
from collections import deque
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

def main():
    mod = 10**9+7
    n = I()
    a = LI()
    a.sort(reverse=True)
    ans = 0
    dig = int(math.log2(a[0])) + 1
    for i in range(dig):
        c0 = 0
        c1 = 0
        for rep in a:
            if (rep>>i)&1:
                c1 += 1
            else:
                c0 += 1
        ans += c0*c1*2**i
    ans %= mod
    print(ans)
    return

if __name__=='__main__':
    main()