#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int a[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  bool is = true;
  for (int i = 1; i < n - 1; ++i) {
    if (a[i] < a[i - 1] && a[i] < a[i + 1]) {
      is = false;
      break;
    }
  }
  if (is) {
    printf("YES\n");
  } else {
    printf("No\n");
  }
  return 0;
}
