program main
 implicit none
 integer N,tmp,i,j,k,ans
 integer, allocatable::p(:)
 read(*,*) N
 allocate(p(1:N))
 read(*,*) p
 
 ans = 1
 do i=2,N
  if(p(k) < p(k-1)) then
   ans = -1
   exit
  end if
 end do
 if(ans == -1) then   
  do i=1,N
   tmp = p(i)
   do j=1,N
    if(j == i) continue
    p(i) = p(j)
    p(j) = tmp
    ans = 1
    do k=2,N
     if(p(k) < p(k-1)) then
      ans = -1
      exit
     end if
    end do
    p(j) = p(i)
    p(i) = tmp
    if(ans == 1) exit
   end do
   if(ans == 1) exit
  end do
 end if
 
 if(ans == -1) then
  write(*,*) 'NO'
 else
  write(*,*) 'YES'
 end if
end program main