def main():
    n = int(input())
    a = list(map(int, input().split()))
    maxa = max(a)
    k = 0
    while 2 ** k <= maxa:
        k += 1
    mod = 10 ** 9 + 7
    mo2 = [1]
    for _ in range(k):
        mo2.append(mo2[-1] * 2)

    p = [[0, 0] for i in range(k)]
    for sa in a:
        for j in range(k):
            if mo2[j] & sa != 0:
                p[j][1] += 1
            else:
                p[j][0] += 1
    res = 0
    for sa in a:
        for j in range(k):
            if mo2[j] & sa != 0:
                res += mo2[j] * p[j][0]
            else:
                res += mo2[j] * p[j][1]
            res %= mod
    print(res // 2)


main()
