#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, arr[10000];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = 0;
  char c = 'i';
  for (i = 1; i < n; i++) {
    if (c == 'i') {
      if (arr[i] > arr[i - 1]) continue;
      if (arr[i] == arr[i - 1])
        c = 'c';
      else
        c = 'd';
    } else if (c == 'c') {
      if (arr[i] == arr[i - 1]) continue;
      if (arr[i] < arr[i - 1])
        c = 'd';
      else
        ans = 1;
    } else {
      if (arr[i] < arr[i - 1])
        continue;
      else
        ans = 1;
    }
  }
  if (ans == 0)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
