#include <bits/stdc++.h>
using namespace std;
long long n, m;
int main() {
  cin >> n;
  long long cnt = n;
  long long arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    if (arr[i] >= arr[i + 1]) {
      cnt = i;
      break;
    }
  }
  for (int i = cnt; i <= n; i++) {
    if (arr[i] != arr[i + 1]) {
      cnt = i;
      break;
    }
  }
  for (int i = cnt; i < n; i++) {
    if (arr[i] <= arr[i + 1]) return cout << "NO", 0;
  }
  cout << "YES";
}
