import Foundation

let n = Int(readLine()!)!
let inputString = readLine()!

var split: [Int] = inputString.components(separatedBy: " ").map{Int(String($0))!}
var exp = split
split.sort { $0 < $1 }
var i = 1
var count = 0
for i in 1...n {
    if (split[i-1] != exp[i-1]) {
        count += 1
    }
    
    if (count == 3) {
        break
    }
}

if (count == 3) {
    print("NO")
} else {
   print("YES") 
}
