program main
  implicit none
  integer :: i, n, k
  integer, allocatable :: p(:), q(:)

  read *, n 
  allocate (p(n))
  read *, p

  do i = 1, n
    if (p(i) /= i) k = k + 1
  end do

  if (k <= 2) then
    print '(a)', 'YES'
  else
    print '(a)', 'NO'
  end if
end program