program xor_sum_4
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, c(0:60) = 0, i, j
  integer(8) :: a(300000) = 0_8, s = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    s = mod(s+a(i),md)
    do j = 0, 60
      if (btest(a(i),j)) c(j) = c(j)+1
    end do
  end do
  s = mod(int(n,8)*s,md)
  do j = 0, 60
    s = modulo(s-int(c(j)*c(j),8)*mod(ibset(0_8,j),md),md)
  end do
  write(*,'(i0)') s
end program xor_sum_4