def read():

    N = int(input().strip())

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

    return N, A





def solve(N, A, L=60, MOD=10**9+7):

    modsum = 0

    for j in range(L):

        count_ones = sum([1 for a in A if (a >> j) & 1])

        # count_ones = sum([(A[i] >> j) & 1 for i in range(N)])

        count_zeros = N - count_ones

        # MODは一度にとる

        modsum +=  (1<<j) * count_zeros * count_ones

        modsum %= MOD

    return modsum





if __name__ == '__main__':

    inputs = read()

    print(("%d" % solve(*inputs)))

import numpy as np





def read():

    N = int(input().strip())

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

    return N, A





def solve(N, A, L=60, MOD=10**9+7):

    A = np.array(A, dtype=np.int64)

    modsum = 0

    for j in range(L):

        B = (A >> j) & 1

        count_ones = np.count_nonzero(B)

        count_zeros = N - count_ones

        # MODは一度にとる

        modsum +=  (1<<j) * count_zeros * count_ones

        modsum %= MOD

    return modsum





if __name__ == '__main__':

    inputs = read()

    print(("%d" % solve(*inputs)))

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A, L=60, MOD=10**9 + 7):
    modsum = 0
    for j in range(L):
        count_ones = sum([1 for a in A if (a >> j) & 1])
        # count_ones = sum([(A[i] >> j) & 1 for i in range(N)])
        count_zeros = N - count_ones
        # MODは一度にとる
        modsum += (1 << j) * count_zeros * count_ones
        modsum %= MOD
    return modsum


if __name__ == "__main__":
    inputs = read()
    print(("%d" % solve(*inputs)))

import numpy as np


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A, L=60, MOD=10**9 + 7):
    A = np.array(A, dtype=np.int64)
    modsum = 0
    for j in range(L):
        B = (A >> j) & 1
        count_ones = np.count_nonzero(B)
        count_zeros = N - count_ones
        # MODは一度にとる
        modsum += (1 << j) * count_zeros * count_ones
        modsum %= MOD
    return modsum


if __name__ == "__main__":
    inputs = read()
    print(("%d" % solve(*inputs)))

+import numpy as np + + +    A = np.array(A, dtype=np.int64) -        count_ones = sum([1 for a in A if (a >> j) & 1]) -        # count_ones = sum([(A[i] >> j) & 1 for i in range(N)]) +        B = (A >> j) & 1 +        count_ones = np.count_nonzero(B)