program zero_or_one_wap
  implicit none
  integer :: n, p(50) = 0, i, m = 0
  read(*,*) n
  read(*,*) p(1:n)
  do i = 1, n
    if (p(i) /= i) m = m+1
  end do
  if (m*(m-2) == 0) then
    write(*,'(a)') "YES"
  else
    write(*,'(a)') "NO"
  end if
  stop
end program zero_or_one_wap