import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let reader=readInts()
let n=reader[0]
var p=readInts()
var sorted=p
sorted.sort { $0 < $1 }
var diff=0

for i in 0..<n{
  if p[i] != sorted[i]{diff+=1}
}

if diff==2||diff==0{print("Yes")}else{print("No")}