#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int arr[maxn];
int main() {
  int t, n;
  cin >> n;
  int maxx = 0, p = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] > maxx) {
      maxx = arr[i];
      p = i;
    }
  }
  int flag = 0;
  for (int i = p + 1; i < n; i++) {
    if (arr[i] > arr[i - 1]) {
      flag = 1;
      break;
    }
  }
  for (int i = p - 1; i >= 0; i--) {
    if (arr[i] < arr[i - 1]) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}
