MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    max_bin_digits = len(bin(max(A))[2:])
    cnts = [0] * max_bin_digits

    for a in A:
        bin_a = bin(a)[2:].zfill(max_bin_digits)
        for i, b in enumerate(bin_a):
            if int(b):
                cnts[-i-1] += 1

    ans = 0
    for i in range(max_bin_digits):
        ans += cnts[i] * (N - cnts[i]) * 2 ** i
        ans %= MOD

    print(ans)

if __name__ == "__main__":
    main()