#include #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++) #define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++) #define ALL(x) x.begin(), x.end() using ll = long long; using namespace std; int main(){ int n; cin >> n; vector a(n); rep(i, n) cin >> a.at(i); bool ans = false, st = false; rep(i, n){ if(a.at(i) > (i+1)) ans = true; else if(a.at(i) == (i+1)){ if(i != 0){ if(st == false) st = true; else ans = true; } }else if(a.at(i) < i){ if(!(st == true && a.at(i) == 0))ans = true; } } if(ans == false) cout << "Yes" << endl; else cout << "No" << endl; return 0; }