#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const long long mod = 998244353;
const int N = 3e5 + 10;
int n;
int a[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    if (a[i] <= a[i - 1] && a[i] <= a[i + 1]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}
