N = gets.chomp.to_i
p = gets.chomp.split(" ").map(&:to_i)

def makeOrder()
  ary = []
  ary.fill(0, N) {|i| i+1}
end

class Array
  def diff(ary)
    retAry = []
    self.each_index{ |i|
      if self[i] != ary[i]
        retAry.push(self[i])
      end
    }
    retAry
  end
end

diffAry = p.diff(makeOrder())

if diffAry.empty?
  puts "YES"
elsif diffAry.length == 2 && p.index(diffAry[0])+1 == diffAry[1]
  puts "YES"
else
  puts "NO"
end
