#include <bits/stdc++.h>
using namespace std;
int n, i, x, y, f, g;
int main() {
  for (cin >> n >> y, i = 1; i < n; i++) {
    cin >> x;
    if (f == 0)
      f |= x <= y;
    else
      g |= x >= y;
    y = x;
  }
  cout << (g ? "NO" : "YES");
}
