let n=Int(readLine()!)!
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
var pp=readInts()
let ppw=pp.sorted()
var count=0
for i in 0...n-1{
  if pp[i]!=ppw[i]{
    count+=1
  }
}
if count==2{
  print("YES")
}else{
  print("NO")
}
  
