package com.thinker.bishi.saima;

import java.util.Scanner;

/**
 * @author lzh
 * <p href="http://exercise.acmcoder.com/online/online_judge_ques?ques_id=1656&konwledgeId=134">
 *     http://exercise.acmcoder.com/online/online_judge_ques?ques_id=1656&konwledgeId=134
 * </p>
 */
public class OverTurnArray {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int len = in.nextInt();
        int[] arr = new int[len];
        for(int i=0;i<len;i++){
            arr[i] = in.nextInt();
        }
        getOverturn(arr,len);

    }
    private static void getOverturn(int[] arr,int len){
        int begin = 0,end = 0;
        boolean flag = false;
        //find begin and end
        for(int i=0;i<len-1;i++){
            if(!flag && arr[i] > arr[i+1]){
                begin = i;flag = true;
            }else if(flag && arr[i] < arr[i+1]){
                end = i;break;
            }
        }
        while (begin < end && begin >= 0 && end <=len-1){
            int tmp = arr[begin];
            arr[begin] = arr[end];
            arr[end] = tmp;
            begin ++;end--;
        }
        flag = true;
        for(int i=0;i<len-1;i++){
            if(arr[i] > arr[i+1]){
                flag = false;
            }
        }
        if(flag){
            System.out.println("yes");
        }else {
            System.out.println("no");
        }
    }
}


