import java.util.Scanner; public class Main { static int[] a = new int[100005]; public static boolean solven(int n) { int flag = 0, left = 0, right = n-1; for(int i = 0; i < n - 1; ++i) { if(flag == 0 && a[i] > a[i+1]) { ++flag; left = i; } if(flag == 1 && a[i] < a[i+1]) { ++flag; right = i; } if(flag == 2 && a[i] > a[i+1]) return false; } if(left > 0 && a[right] < a[left-1]) return false; if(right < n-1 && a[left] > a[right+1]) return false; return true; } public static void main(String[] args) { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); for(int i = 0; i < n; ++i) a[i] = cin.nextInt(); if(solven(n)) System.out.println("yes"); else System.out.println("no"); } }