from sys import stdin

def main():

    n = int(stdin.readline().rstrip())

    a = list(map(int,stdin.readline().rstrip().split()))

    mod = 10**9+7

    point = 0

    for i in range(61):

        now = sum(1 for j in a if(j >> i)&1)

        point += now*(n-now)*(2**i)%mod

        point %= mod

    print(point)

if __name__ == "__main__":

    main()
from sys import stdin

import numpy as np

def main():

    n = int(stdin.readline().rstrip())

    a = list(map(int,stdin.readline().rstrip().split()))

    a = np.array(a)

    mod = 10**9+7

    point = 0

    for i in range(61):

        b = (a >> i)&1

        x = np.count_nonzero(b)

        y = n-x

        point += x*y*(2**i)%mod

    print((point%mod))

if __name__ == "__main__":

    main()
from sys import stdin


def main():
    n = int(stdin.readline().rstrip())
    a = list(map(int, stdin.readline().rstrip().split()))
    mod = 10**9 + 7
    point = 0
    for i in range(61):
        now = sum(1 for j in a if (j >> i) & 1)
        point += now * (n - now) * (2**i) % mod
        point %= mod
    print(point)


if __name__ == "__main__":
    main()

from sys import stdin
import numpy as np


def main():
    n = int(stdin.readline().rstrip())
    a = list(map(int, stdin.readline().rstrip().split()))
    a = np.array(a)
    mod = 10**9 + 7
    point = 0
    for i in range(61):
        b = (a >> i) & 1
        x = np.count_nonzero(b)
        y = n - x
        point += x * y * (2**i) % mod
    print((point % mod))


if __name__ == "__main__":
    main()

+import numpy as np +    a = np.array(a) -        now = sum(1 for j in a if (j >> i) & 1) -        point += now * (n - now) * (2**i) % mod -        point %= mod -    print(point) +        b = (a >> i) & 1 +        x = np.count_nonzero(b) +        y = n - x +        point += x * y * (2**i) % mod +    print((point % mod))