open System

let N = stdin.ReadLine()|>int
let p = stdin.ReadLine().Split()|>Array.map int
[<EntryPoint>]
let main argv =
    let mutable ans = 0
    for i in [0..N-1] do
        ans <- ans + if p.[i]<>i+1 then 1 else 0
    match (ans-2)>0 with
    |true -> printfn "%s" "NO"
    |false -> printfn "%s" "YES"
    0
   