import numpy as np

 

 

def solve(string):

    n, *a = list(map(int, string.split()))

    # a = ["{:060b}".format(_a) for _a in a]

    a = np.asarray(a, dtype=np.int64)

    m = 10**9 + 7

    ans = 0

    for i in range(60):

        s = int((a & 1).sum())

        a >>= 1

        # ans += s * (n - s) * pow(2, 59 - i, m)

        ans += s * (n - s) * pow(2, i, m) % m

        ans %= m

    return str(ans)

 

 

if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))
import numpy as np

import math

n = int(eval(input()))

A = np.fromstring(eval(input()),dtype=np.int64,sep=" ")

#rng = int(math.log2(np.max(A)))+1

sum = 0

d = 10**9+7

for bit in range(64):

    c = int((A & 1).sum())

    sum += c *(n-c)*(1<<bit)%d

    A = A>>1



print((sum %(d)))
import numpy as np


def solve(string):
    n, *a = list(map(int, string.split()))
    # a = ["{:060b}".format(_a) for _a in a]
    a = np.asarray(a, dtype=np.int64)
    m = 10**9 + 7
    ans = 0
    for i in range(60):
        s = int((a & 1).sum())
        a >>= 1
        # ans += s * (n - s) * pow(2, 59 - i, m)
        ans += s * (n - s) * pow(2, i, m) % m
        ans %= m
    return str(ans)


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

import numpy as np
import math

n = int(eval(input()))
A = np.fromstring(eval(input()), dtype=np.int64, sep=" ")
# rng = int(math.log2(np.max(A)))+1
sum = 0
d = 10**9 + 7
for bit in range(64):
    c = int((A & 1).sum())
    sum += c * (n - c) * (1 << bit) % d
    A = A >> 1
print((sum % (d)))

+import math - -def solve(string): -    n, *a = list(map(int, string.split())) -    # a = ["{:060b}".format(_a) for _a in a] -    a = np.asarray(a, dtype=np.int64) -    m = 10**9 + 7 -    ans = 0 -    for i in range(60): -        s = int((a & 1).sum()) -        a >>= 1 -        # ans += s * (n - s) * pow(2, 59 - i, m) -        ans += s * (n - s) * pow(2, i, m) % m -        ans %= m -    return str(ans) - - -if __name__ == "__main__": -    import sys - -    print((solve(sys.stdin.read().strip()))) +n = int(eval(input())) +A = np.fromstring(eval(input()), dtype=np.int64, sep=" ") +# rng = int(math.log2(np.max(A)))+1 +sum = 0 +d = 10**9 + 7 +for bit in range(64): +    c = int((A & 1).sum()) +    sum += c * (n - c) * (1 << bit) % d +    A = A >> 1 +print((sum % (d)))