#include <bits/stdc++.h>
using namespace std;
long long int Ceil(long long int a, long long int b) {
  return a / b + (a % b != 0);
}
long long int fastModExp(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b = b >> 1;
  }
  return res;
}
map<long long int, long long int> mpx;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector<long long int> v;
  long long int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  };
  int a = max_element(v.begin(), v.end()) - v.begin();
  long long int top = v[a];
  bool p = true;
  long long int r;
  int j = a + 1, i = a - 1;
  while (true) {
    if (i >= 0 && j < n) {
      r = max(v[i], v[j]);
      if (r >= top) {
        p = false;
        break;
      } else {
        top = r;
        if (r == v[j])
          j++;
        else
          i--;
      }
    } else if (i < 0 && j >= n) {
      break;
    } else if (i < 0) {
      r = v[j];
      if (r >= top) {
        p = false;
        break;
      } else {
        top = r;
        j++;
      }
    } else if (j >= n) {
      r = v[i];
      if (r >= top) {
        p = false;
        break;
      } else {
        top = r;
        i--;
      }
    }
  }
  if (p)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
