input = readlines()

n = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

if list.join('') == list.sort().join('')
  puts 'YES'
  exit()
end

list.each_with_index do |l1, i1|
  list.each_with_index do |l2, i2|
    next if i1 == i2
    tmp = list.clone
    tmp[i1] = list[i2]
    tmp[i2] = list[i1]
    if tmp.join('') == tmp.sort().join('')
      puts 'YES'
      exit()
    end
  end
end

puts 'NO'