#include <bits/stdc++.h>
using namespace std;
vector<long long int> visited(100005LL);
vector<vector<long long int> > graph(100005LL);
vector<long long int> ans = {-1};
vector<long long int> level(100005LL);
vector<long long int> ind(100005LL);
long long int sz[100005LL];
void dfs(long long int node, long long int par) {
  visited[node] = 1;
  if (node == 1)
    level[1] = 0;
  else
    level[node] = level[par] + 1;
  ans.push_back(node);
  for (auto x : graph[node]) {
    if (!visited[x]) {
      dfs(x, node);
      sz[node] += sz[x];
    }
  }
  ++sz[node];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> arr(n);
  for (auto &x : arr) cin >> x;
  long long int ind1 = 0;
  long long int ind2 = n - 1;
  for (long long int i = 0; i < n - 1; i++) {
    if (arr[i] < arr[i + 1])
      ind1 += 1;
    else
      break;
  }
  for (long long int i = n - 2; i >= 0; i--) {
    if (arr[i] > arr[i + 1])
      ind2 -= 1;
    else {
      break;
    }
  }
  for (long long int i = ind1; i < ind2; i += 1) {
    if (arr[i] != arr[i + 1]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "yes\n";
}
