"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = xs[0];
   let p = xs[1].trim().split(' ');
   let ans = 0;
   for(let i =0; i<=N; i++){
     if(p[i] > p[i+1]){
     ans = ans + 1;
     }else{
     ans = ans + 0;
     }
   }
     if(ans == 0 || ans == 1){
     console.log('YES'); 
     }else{
     console.log('NO')
     }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));