N = gets.to_i
q = gets.split.map(&:to_i)

if q == q.sort
  puts 'YES'
  exit
end

N.times do |i|
  (i+1).upto(N-1) do |j|
    q[i], q[j] = q[j], q[i]
    sorted = true
    1.upto(N-1) do |k|
      if q[k-1] > q[k]
        sorted = false
        break
      end
    end

    if sorted
      puts 'YES'
      exit
    end

    q[i], q[j] = q[j], q[i]
  end
end

puts 'NO'
