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

  read *, n 
  allocate (p(n), q(n))
  read *, p
  q(:) = p(:)
  if (minval(q(2:n) - q(1:n-1)) > 0) ans = .true.
  do i = 1, n
    do j = i+1, n
      q(:) = p(:)
      q(i) = p(j)
      q(j) = p(i)
      ans = .true.
      do k = 1, n
        if (q(k) /= k) ans = .false.
      end do
      if (ans == .true.) goto 10
    end do
  end do
  10 if (ans) then
    print '(a)', 'YES'
  else
    print '(a)', 'NO'
  end if
end program