//include,using,define等 #pragma region header #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // =============================================================== //using系 #pragma region header using namespace std; using ll = long long; using lint = long long; using vl = vector; using vvl = vector>; using vvi = vector>; using vs = vector; using vc = vector; using vcc = vector>; using vm = vector; using vmm = vector>; using pii = pair; using psi = pair; using ld = long double; using ull = unsigned long long; using ui = unsigned int; using qul = queue; using pql = priority_queue; const int dx[] = { 1,0,-1,0 }; const int dy[] = { 0,1,0,-1 }; constexpr ll mod = 1000000007; constexpr long double pi = 3.141592653589793238462643383279; #pragma endregion // ======================================================================== //define #pragma region header #define rep(i, n) for(ll i = 0; i < n; i++) #define REP(i, n) for(ll i = 1; i <= n; i++) #define INF (ll)10000000000000000 #define mod (ll)1000000007 #pragma endregion #pragma endregion int main() { int n; cin >> n; vector d(n); for (int i = 0; i < n; i++) cin >> d[i]; bool s = false; if (d[0] != 0) s = true; for (int i = 1; i < n; i++) { if (d[i] != 0) s = false; } if (s) { cout << "Yes" << endl; return 0; } map mp; for (int i = 1; i < n; i++) { if (d[i] != 0) mp[(i + 1) - d[i]]++; } bool h = false; bool cnt = false; if (mp[0] == 0) { cout << "No" << endl; return 0; } if (mp[0] > 1) { cout << "No" << endl; return 0; } for (int i = 1; i < n; i++) { if (mp[i] == 0) { cnt = true; } if (mp[i] == 1) { if (cnt) { cout << "No" << endl; return 0; } } if (mp[i] > 1) { if (mp[i + 1] == 0) cnt = true; else { cout << "No" << endl; return 0; } } } if (cnt) cout << "Yes" << endl; else cout << "No" << endl; return 0; }