#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
int cmp(const void *a, const void * b){
int *p1 = (int*)a;
int *p2 = (int*)b;
return *p1 - *p2;
}
void solve(){
int n; scanf("%d", &n);
int a[n+1];
for(int i=1; i <=n; i++){
scanf("%d", a + i);
}
int check[n+2] = {0};
check[a[1]] = 1; //a[i] la vi tri ghe ma khach thu i ngoi;
for(int i=2; i <=n; i++){
if(!check[a[i] + 1] && !check[a[i] - 1]){
printf("NO\n");
return;
}
check[a[i]] = 1; //dat vi tri ghe a[i] = 1 (da co nguoi ngoi)
}
printf("YES\n");
}
int main(){
int typetest = 0;
if(typetest){
int t; scanf("%d", &t);
while(t--){
solve();
}
}else solve();
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKCmludCBjbXAoY29uc3Qgdm9pZCAqYSwgY29uc3Qgdm9pZCAqIGIpewogICAgaW50ICpwMSA9IChpbnQqKWE7CiAgICBpbnQgKnAyID0gKGludCopYjsKICAgIHJldHVybiAqcDEgIC0gKnAyOwp9CgoKCnZvaWQgc29sdmUoKXsKICAgIGludCBuOyBzY2FuZigiJWQiLCAmbik7CiAgICBpbnQgYVtuKzFdOwogICAgZm9yKGludCBpPTE7IGkgPD1uOyBpKyspewogICAgICAgIHNjYW5mKCIlZCIsIGEgKyBpKTsKICAgIH0KICAgIGludCBjaGVja1tuKzJdID0gezB9OwogICAgY2hlY2tbYVsxXV0gPSAxOyAvL2FbaV0gbGEgdmkgdHJpIGdoZSBtYSBraGFjaCB0aHUgaSBuZ29pOyAKICAgIGZvcihpbnQgaT0yOyBpIDw9bjsgaSsrKXsKICAgICAgICBpZighY2hlY2tbYVtpXSArIDFdICYmICAhY2hlY2tbYVtpXSAtIDFdKXsKICAgICAgICAgICAgcHJpbnRmKCJOT1xuIik7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgY2hlY2tbYVtpXV0gPSAxOyAvL2RhdCB2aSB0cmkgZ2hlIGFbaV0gPSAxIChkYSBjbyBuZ3VvaSBuZ29pKQogICAgfQogICAgcHJpbnRmKCJZRVNcbiIpOwp9CgppbnQgbWFpbigpewogICAgaW50IHR5cGV0ZXN0ID0gMDsKICAgIGlmKHR5cGV0ZXN0KXsKICAgICAgICBpbnQgdDsgc2NhbmYoIiVkIiwgJnQpOwogICAgICAgIHdoaWxlKHQtLSl7CiAgICAgICAgICAgIHNvbHZlKCk7CiAgICAgICAgfQogICAgfWVsc2Ugc29sdmUoKTsKfQ==