implicit none

integer :: N
integer, allocatable :: p(:)
integer :: i,s

read *, N
allocate(p(N))

read *, (p(i),i=1,N)

s = 0
do i = 1, N
   if (p(i) /= i) then
      s = s + 1
   endif
enddo

if (s == 0 .or. s == 2) then
   write(6,'(a)') 'YES'
else
   write(6,'(a)') 'NO'
endif
stop
end