# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, As):
    import math
    x = math.ceil(math.log2(max(As)))
    ans = 0
    for i in range(x):
        count0 = 0
        count1 = 0
        for A in As:
            if (A >> i) % 2 == 0:
                count0 += 1
            else:
                count1 += 1
        # print(i, count0, count1)
        ans += count0 * count1 * (2 ** i)
        ans = ans % (10 ** 9 + 7)
    print(ans)


if __name__ == '__main__':
    N = int(input())
    As = [int(i) for i in input().split()]
    # N = 3 * 10 ** 5
    # import random
    # As = [random.randint(0, 2 ** 60) for _ in range(N)]
    solve(N, As)
