#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int a[n];
  int flag = 0;
  int flag2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1] && flag == 0) {
      flag = 0;
    } else if (a[i] == a[i + 1] && flag2 == 0) {
      flag = 1;
      flag2 = 0;
    } else if (a[i] > a[i + 1]) {
      flag2 = 1;
      flag = 1;
    } else {
      ans = 1;
      break;
    }
  }
  if (ans == 1)
    cout << "NO\n";
  else
    cout << "YES" << endl;
  return 0;
}
