import sys

input = sys.stdin.readline





def main():

    N = int(eval(input()))

    A = list(map(int, input().split()))

    B = [0]*60

    for a in A:

        for i in range(len(B)):

            if a & (2**i):

                B[i] += 1

    ans = 0

    for i, b in enumerate(B):

        ans += 2**i * b * (N-b)

    ans %= 10**9+7

    print(ans)





if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline





def main():

    N = int(eval(input()))

    A = list(map(int, input().split()))

    B = [0]*60

    for a in A:

        for i in range(len(B)):

            if (a >> i) & 1:

                B[i] += 1

    ans = 0

    for i, b in enumerate(B):

        ans += 2**i * b * (N-b)

    ans %= 10**9+7

    print(ans)





if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = [0] * 60
    for a in A:
        for i in range(len(B)):
            if a & (2**i):
                B[i] += 1
    ans = 0
    for i, b in enumerate(B):
        ans += 2**i * b * (N - b)
    ans %= 10**9 + 7
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = [0] * 60
    for a in A:
        for i in range(len(B)):
            if (a >> i) & 1:
                B[i] += 1
    ans = 0
    for i, b in enumerate(B):
        ans += 2**i * b * (N - b)
    ans %= 10**9 + 7
    print(ans)


if __name__ == "__main__":
    main()

-            if a & (2**i): +            if (a >> i) & 1: