program xor_sum4
    implicit none
    integer(8),parameter:: md = 1000000007
    integer(4):: i,j,k
    integer(4):: n
    integer(8),allocatable::a(:), total_bits(:)
    integer(8):: ans=0
    
    read*, n
    allocate(a(n))
    allocate(total_bits(0:60), source=0_8)
    read*,a(:)

    do i=1,n
        do j=0,60
            if (btest(a(i),j)) total_bits(j) = total_bits(j) + 1
        end do
    end do
    
    do i=0,60
        ans = mod(ans + mod(lshift(total_bits(i)*(n-total_bits(i)),i),md),md)
    end do

    print*, ans

end program xor_sum4