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

def get_bit_count(digit, A):
    bit_count = 0
    for a in A:
        bit = (a >> digit) & 1
        bit_count += bit
    return bit_count

def get_bit_counts(A, MAXBIT = 60):
    bitcount = [0 for i in range(MAXBIT)]  # x < 2**60
    for a in A:
        for i in range(MAXBIT):
            bitcount[i] = get_bit_count(i, A)
    return bitcount


def solve(N, A, MOD=1000000007):
    answer = 0
    for i in range(len(A)):
        left_counts = get_bit_counts(A[i:i+1])
        right_counts = get_bit_counts(A[i+1:])
        for d, (l, r) in enumerate(zip(left_counts, right_counts)):
            if l == 0:
                adder = r << d
            else:
                adder = (len(A[i+1:]) - r) << d
            answer = (answer + adder) % MOD
    return answer

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