import sys





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n = int(input().rstrip('\n'))

    a = list(map(int, input().rstrip('\n').split()))

    ls = [0] * 60

    t = 0

    for i in range(60):

        for av in a:

            ls[i] += av >> i & 1

        t += 2 ** i * ls[i] * (n - 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()))

    dp = [0] * 61

    for i in range(60, -1, -1):

        for v in a:

            dp[i] += v >> i & 1

    t = 0

    for i in range(61):

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

        t %= mod

    print(t)





if __name__ == '__main__':

    solve()

import sys


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n = int(input().rstrip("\n"))
    a = list(map(int, input().rstrip("\n").split()))
    ls = [0] * 60
    t = 0
    for i in range(60):
        for av in a:
            ls[i] += av >> i & 1
        t += 2**i * ls[i] * (n - 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()))
    dp = [0] * 61
    for i in range(60, -1, -1):
        for v in a:
            dp[i] += v >> i & 1
    t = 0
    for i in range(61):
        t += dp[i] * (n - dp[i]) * pow(2, i)
        t %= mod
    print(t)


if __name__ == "__main__":
    solve()

-    input = sys.stdin.readline +    readline = sys.stdin.buffer.readline -    n = int(input().rstrip("\n")) -    a = list(map(int, input().rstrip("\n").split())) -    ls = [0] * 60 +    n = int(readline()) +    a = list(map(int, readline().split())) +    dp = [0] * 61 +    for i in range(60, -1, -1): +        for v in a: +            dp[i] += v >> i & 1 -    for i in range(60): -        for av in a: -            ls[i] += av >> i & 1 -        t += 2**i * ls[i] * (n - ls[i]) +    for i in range(61): +        t += dp[i] * (n - dp[i]) * pow(2, i)