n = gets.to_i
a = gets.split.map(&:to_i)

ans = a == a.sort
n.times do |i|
  (i+1).upto(n-1) do |j|
    t = a.dup
    k = t[i]
    t[i] = t[j]
    t[j] = k
    ans = true if t == t.sort
  end
end
puts ans ? "YES" : "NO"