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

    largest = max(As)
    digits = len(bin(largest))-2

    binaries = [format(i, f'0{digits}b') for i in As]

    total = 0
    for i in range(digits):
        t = [int(n[i]) for n in binaries]
        ones = sum(t)
        zeros = N - ones
        r = ones * zeros
        total += (2 ** (digits-i-1)) * r
        total = total % (10**9 + 7)

    print(total)


if __name__ == '__main__':
    main()
