using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class Solution {

    /*
     * Complete the canModify function below.
     */
    static string canModify(int[] a) {
        /*
         * Write your code here.
         */
        
        int currentValue = 0;
        int changesCount = 0;
        string answer = "YES";
     
        for(int i = 0;i<a.Length;i++)
        {
            if(currentValue < a[i])
            {
                currentValue = a[i];
            }
            else if(changesCount < 1)
            {
               changesCount++;
            }
            else
            {
                answer = "NO";
                break;
            }
        }
        
        return answer;
        
        

    }

    static void Main(string[] args) {
        TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);

        int n = Convert.ToInt32(Console.ReadLine());

        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), aTemp => Convert.ToInt32(aTemp));
      
        string result = canModify(a);
        

        textWriter.WriteLine(result);
        


        textWriter.Flush();
        textWriter.Close();
    }
}