#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10 ** 9 + 7


def main():
    N = II()
    targets = LI()

    ttl_bins = [[0]*60 for i in range(N)]
    for i in range(1, N):
        target = targets[N-i]
        target_str = format(target, f"0{60}b")
        for keta in range(60):
            ttl_bins[N-i-1][keta] = ttl_bins[N -
                                             i][keta] + int(target_str[keta])

    ttl_final = [0]*60
    for i in range(N-1):
        target = targets[i]
        target_str = format(target, f"0{60}b")
        for keta in range(60):
            keta_int = int(target_str[keta])
            if keta_int == 0:
                ttl_others_1 = ttl_bins[i][keta]
                ttl_final[59 - keta] += ttl_others_1
            if keta_int == 1:
                ttl_others_0 = (N - i - 1) - ttl_bins[i][keta]
                ttl_final[59 - keta] += ttl_others_0

    ans = 0
    for i in range(60):
        ans += ttl_final[i] * pow(2, i, MOD)
        ans %= MOD

    print(ans)


main()
