#include <bits/stdc++.h>
using namespace std;
long long ceiling(long long x, long long y) {
  if (x % y)
    return ((x / y) + 1);
  else
    return (x / y);
}
long long gcd(long long x, long long y) {
  return ((y == 0) ? x : gcd(y, x % y));
}
long long lcm(long long x, long long y) { return ((x * y) / gcd(x, y)); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int index = 1;
  for (int i = index; i <= n - 1; i++) {
    if (arr[i] > arr[i - 1])
      index++;
    else
      break;
  }
  for (int i = index; i <= n - 1; i++) {
    if (arr[i] == arr[i - 1])
      index++;
    else
      break;
  }
  for (int i = index; i <= n - 1; i++) {
    if (arr[i] < arr[i - 1])
      index++;
    else
      break;
  }
  if (index == n)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
