import sys





def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7

    n = int(readline())

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

    ls = [0] * 65

    for v in a:

        tt = bin(v)

        for i in range(len(tt)-2):

            ls[i] += int(tt[-i-1])

    t = 0

    for i in range(len(ls)):

        t += pow(2, i, mod) * (n - ls[i]) * ls[i]

        t %= mod

    print(t)





if __name__ == '__main__':

    solve()

import sys



def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7

    n = int(readline())

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

    ls = [0] * 60

    t = 0

    for i in range(60):

        for v in a:

            ls[i] += (v >> i) & 1

        t += pow(2, i, mod) * (n - ls[i]) * ls[i]

        t %= mod

    print(t)





if __name__ == '__main__':

    solve()

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ls = [0] * 65
    for v in a:
        tt = bin(v)
        for i in range(len(tt) - 2):
            ls[i] += int(tt[-i - 1])
    t = 0
    for i in range(len(ls)):
        t += pow(2, i, mod) * (n - ls[i]) * ls[i]
        t %= mod
    print(t)


if __name__ == "__main__":
    solve()

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ls = [0] * 60
    t = 0
    for i in range(60):
        for v in a:
            ls[i] += (v >> i) & 1
        t += pow(2, i, mod) * (n - ls[i]) * ls[i]
        t %= mod
    print(t)


if __name__ == "__main__":
    solve()

-    ls = [0] * 65 -    for v in a: -        tt = bin(v) -        for i in range(len(tt) - 2): -            ls[i] += int(tt[-i - 1]) +    ls = [0] * 60 -    for i in range(len(ls)): +    for i in range(60): +        for v in a: +            ls[i] += (v >> i) & 1