#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a, b;
  int flag = 1;
  int ans = 1;
  scanf("%d", &n);
  scanf("%d", &a);
  if (n == 1) {
    printf("YES\n");
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    scanf("%d", &b);
    if (flag == 0 && b > a) {
      ans = 0;
      break;
    }
    if (flag == -1 && b >= a) {
      ans = 0;
      break;
    }
    if (b == a) {
      flag = 0;
    }
    if (b < a) {
      flag = -1;
    }
    a = b;
  }
  if (ans) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
