#include<iostream> using namespace std; #include<stack> #include<cstdio> const int maxn = 1000+5; int a[maxn]; int main(){ int n; scanf("%d",&n);//3 stack<int>s; int A = 1,B = 1;//A为进站,B为出站 for(int i=1;i<=n;i++){//3 1 2 scanf("%d",&a[i]); } int ok = 1; while(B<=n){ if(A==a[B]){A++;B++;} else if(!s.empty()&&s.top()==a[B]){s.pop();B++;} else if(A<=n){s.push(A++);}//s.push(1);A=2; s.push(2);A=3; else{ok = 0;break;} } printf("%s\n",ok?"Yes":"No"); return 0; }