#!/bin/env ruby

s = STDIN.readlines
n = s[0]
a = s[1].split(" ").map(&:to_i)

count = 0

a.each_index do |i|
  if i+1 == a[i]
  else
    count = count + 1
  end
end

if count > 2
  puts "NO"
else
  puts "YES"
end
