def zero_or_swap(p)
  sorted = p.sort
  count = 0
  0.upto(p.size - 1) do |i|
    if sorted[i] != p[i]
      count += 1
      return 'NO' if count > 2
    end
  end
  'YES'
end

n = gets.chomp.to_i
p = gets.split.map(&:to_i)
puts zero_or_swap(p)
