#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n, i;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 2; i <= n; i++)
    if (a[i] < a[i - 1]) break;
  for (; i <= n; i++)
    if (a[i] > a[i - 1]) break;
  if (i != n + 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
