program abc135b
   implicit none
   integer :: n, counter, i, j
   integer, allocatable :: p(:), q(:)

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

   do i = 1, n
      q(i) = i
   end do

   counter = 0
   do i = 1, n
      if (p(i) /= q(i)) counter = counter + 1
   end do

   if ( counter <= 2) then
      write(*, *) 'YES'
   else
      write(*,*) 'NO'
   end if
end program abc135b
