#include using namespace std; #define int long long #define REP(i,n) for(int i = 0;i < (int)(n);i++) #define RREP(i,n) for(int i = (int)n-1;i >= 0;i--) #define FOR(i,s,n) for(int i = s;i < (int)n;i++) #define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--) #define ALL(a) a.begin(),a.end() #define IN(a, x, b) (a<=x && xinline bool CHMAX(T&a,T b){if(ainline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;} constexpr long long INF = 1e18; signed main(){ int N; cin>>N; vectora(N); int l = -1,r = -1; REP(i,N){ cin>>a[i]; a[i]--; } if(a[0]==N-1||a[N-1]==0||a[0]>a[N-1]){ cout<<"No"<ans; vectortmp; int ma = N - 1; FOR(i,1,N){ if(a[i] == ma){ ma--; while(tmp.size()){ int t = tmp.back(); if(t==ma)ma--; tmp.pop_back(); ans.push_back(t); } ans.push_back(a[i]); }else{ tmp.push_back(a[i]); } } cout<<"Yes"<