program main
    implicit none
    integer n
    integer a, i
    integer warn(2)
    integer, allocatable :: list(:)
    warn = 0
    a = 0
    read*,n
    allocate(list(n))

    read*, list
    do i=1,n
        if (list(i) /= i)then
            a = a + 1
            warn(a) = i
        endif

        if (a>2)then
            print'(a)','NO'
            stop
        endif
    enddo

    if (a == 2 .or. a==0)then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    endif
  
end program main