def main():
    N = int(input())
    A = list(map(int, input().split()))

    result = 0
    bs = [0] * N
    for b in range(60):
        a = [(e >> b) & 1 for e in A]
        bs[N - 1] = a[N - 1]
        t = bs[N - 1]
        for i in range(N - 2, -1, -1):
            t += a[i]
            bs[i] = t

        t = 0
        for i in range(N - 1):
            if a[i] == 0:
                t += bs[i + 1]
            else:
                t += (N - (i + 1)) - bs[i + 1]
        result = (result + t * (1 << b)) % 1000000007
    print(result)
main()
