#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int flag = 0;
  int fl = 0;
  for (int i = 1; i < n; i++) {
    if (flag == 0) {
      if (a[i] > a[i - 1])
        continue;
      else if (a[i] == a[i - 1])
        flag = 1;
      else if (a[i] < a[i - 1])
        flag = 2;
    } else if (flag == 1) {
      if (a[i] > a[i - 1]) {
        fl = 1;
        break;
      } else if (a[i] == a[i - 1])
        continue;
      else if (a[i] < a[i - 1])
        flag = 2;
    } else if (flag == 2) {
      if (a[i] >= a[i - 1]) {
        fl = 1;
        break;
      }
    }
  }
  printf("%s\n", fl ? "NO" : "YES");
  return 0;
}
