#include <bits/stdc++.h>
using namespace std;
long long n, a[200001];
bool bj, pd;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      f = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
int main() {
  int i;
  n = read();
  for (i = 1; i <= n; i++) {
    a[i] = read();
  }
  for (i = 2; i <= n; i++) {
    if (a[i] < a[i - 1]) {
      bj = true;
    }
    if (bj && a[i] > a[i - 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
