#include <bits/stdc++.h>
using namespace std;
int arr[1024 * 1024];
int main() {
  int n, maxv = 0, pos;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] > maxv) {
      maxv = arr[i];
      pos = i;
    }
  }
  bool flag = true;
  for (int i = pos + 1; i <= n; i++) {
    if (arr[i] >= arr[i - 1]) flag = false;
  }
  for (int i = pos - 1; i > 0; i--)
    if (arr[i] >= arr[i + 1]) flag = false;
  sort(arr + 1, arr + 1 + n);
  for (int i = 2; i <= n; i++)
    if (arr[i] == arr[i - 1]) flag = false;
  printf("%s", flag ? "YES" : "NO");
}
