program main
  implicit none

  integer :: n, p(50), i, c=0

  read(*,*)n
  read(*,*)(p(i),i = 1, n)
  
  do i = 1, n
    if ((p(i) - i) /= 0) then
      c = c + 1
    end if
  end do
  if ((c == 2) .or. (c == 0)) then
    write(*,*)"YES"
  else
    write(*,*)"NO"
  end if

end program main