program test
implicit none
integer::N,i,c
integer,allocatable::p(:)
	c=0
	read*,N
	allocate(p(N))
	read(*,*)(p(i),i=1,N)
    	do i=1,N
        	if(i==p(i)) then
				c=c
        	else 
        		c=c+1
        	end if
        end do
    if(c==0)then
    	print*,'YES'
    else if(c==2)then
    	print*,'YES'
    else 
    	print*,'NO'
    end if
end program test