#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100], i, j, k, s = 0;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n - 1; i++) {
    if (a[i + 1] <= a[i]) break;
  }
  for (j = i; j < n - 1; j++) {
    if (a[j + 1] > a[j]) {
      s++;
      cout << "NO";
      break;
    }
    if (a[j + 1] < a[j]) break;
  }
  if (s == 0) {
    for (k = j; k < n - 1; k++) {
      if (a[k + 1] < a[k])
        continue;
      else
        break;
    }
    if (k == n - 1)
      cout << "YES";
    else
      cout << "NO";
  }
}
