a = gets.to_i
n = gets.split.map(&:to_i)
a.times{|t|
  if n[t] != t + 1 then
    n[n.index(t+1)] = n[t]
    n[t] = t + 1
    break
  end
    }
  a.times{|t|
  if n[t] != t + 1 then
    print "NO"
    break
  end
  if t == a-1 then
    print "YES"
  end
    }