let a=Int(readLine()!)!
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var i = 0
var diff = 0

for i in 0..<a {
  if( arr[i] != i + 1 ) {
    diff += 1
  }

}

if ( diff <= 2 ) {
  print( "YES" )
} else {
  print( "NO" )
}