func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace fastIO {   bool IOerror = 0;   inline char nc() {     static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;     if (p1 == pend) {       p1 = buf;       pend = buf + fread(buf, 1, 100000, stdin);       if (pend == p1) {         IOerror = 1;         return -1;       }     }     return *p1++;   }   inline bool blank(char ch) {     return ch ==     || ch ==   n  || ch ==   r  || ch ==   t ;   }   inline void read(long long &x) {     char ch;     long long f = 1;     while (blank(ch = nc()))       ;     while (ch ==  - ) f = -f, ch = nc();     if (IOerror) return;     for (x = ch -  0 ; (ch = nc()) >=  0  && ch <=  9 ; x = x * 10 + ch -  0 )       ;     x *= f;   }   inline void read(int &x) {     char ch;     int f = 1;     while (blank(ch = nc()))       ;     while (ch ==  - ) f = -f, ch = nc();     if (IOerror) return;     for (x = ch -  0 ; (ch = nc()) >=  0  && ch <=  9 ; x = x * 10 + ch -  0 )       ;     x *= f;   }   inline void read(char *s) {     char ch;     while (blank(ch = nc()))       ;     if (IOerror) return;     int i = 0;     for (; !blank(ch); s[i++] = ch, ch = nc())       ;     s[i] =   0 ;   }   };  // namespace fastIO   using namespace fastIO;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n;   int p[300010];   int c[500010];   int ans[300010];   class Treap {    public:     struct treap_point {       int l, r, x, rep, son, rnd;     } t[500010];     int treesz, root;     inline void update(int k) {       t[k].son = t[t[k].l].son + t[t[k].r].son + t[k].rep;     }     inline void right_rotate(int &k) {       int tt = t[k].l;       t[k].l = t[tt].r;       t[tt].r = k;       update(k);       update(tt);       k = tt;     }     inline void left_rotate(int &k) {       int tt = t[k].r;       t[k].r = t[tt].l;       t[tt].l = k;       update(k);       update(tt);       k = tt;     }     inline void insert_to_tree(int &k, int x) {       if (!k) {         k = ++treesz;         t[k].x = x;         t[k].rnd = rand();         t[k].son = t[k].rep = 1;         t[k].l = t[k].r = 0;         return;       }       t[k].son++;       if (x == t[k].x) {         t[k].rep++;         return;       }       if (x < t[k].x) {         insert_to_tree(t[k].l, x);         if (t[t[k].l].rnd < t[k].rnd) right_rotate(k);       }       if (x > t[k].x) {         insert_to_tree(t[k].r, x);         if (t[t[k].r].rnd < t[k].rnd) left_rotate(k);       }     }     inline bool delete_from_tree(int &k, int x) {       if (!k) return 0;       if (x == t[k].x) {         if (t[k].rep > 1) {           t[k].rep--;           t[k].son--;           return 1;         }         if (!t[k].l || !t[k].r) {           k = t[k].l + t[k].r;           return 1;         }         if (t[t[k].l].rnd < t[t[k].r].rnd) {           right_rotate(k);           return delete_from_tree(k, x);         }         left_rotate(k);         return delete_from_tree(k, x);       }       int res;       if (x < t[k].x) {         res = delete_from_tree(t[k].l, x);         if (res) t[k].son--;         return res;       }       res = delete_from_tree(t[k].r, x);       if (res) t[k].son--;       return res;     }     inline int get_succ_in_tree(int k, int x) {       if (!k) return -1;       int sv;       if (x < t[k].x) {         sv = get_succ_in_tree(t[k].l, x);         return sv == -1 ? t[k].x : sv;       }       return get_succ_in_tree(t[k].r, x);     }     inline int get_pred_in_tree(int k, int x) {       if (!k) return -1;       int sv;       if (x > t[k].x) {         sv = get_pred_in_tree(t[k].r, x);         return sv == -1 ? t[k].x : sv;       }       return get_pred_in_tree(t[k].l, x);     }     inline int ask_kth_in_tree(int k, int x) {       if (!k) return -1;       if (x <= t[t[k].l].son) return ask_kth_in_tree(t[k].l, x);       if (x > t[t[k].l].son + t[k].rep)         return ask_kth_in_tree(t[k].r, x - t[t[k].l].son - t[k].rep);       return t[k].x;     }     inline int ask_rank_in_tree(int k, int x) {       if (!k) return -1;       if (x == t[k].x) return t[t[k].l].son + 1;       if (x < t[k].x) return ask_rank_in_tree(t[k].l, x);       return t[t[k].l].son + t[k].rep + ask_rank_in_tree(t[k].r, x);     }     inline void init() { treesz = root = 0; }     inline void insert(int x) { insert_to_tree(root, x); }     inline int del(int x) { return delete_from_tree(root, x); }     inline int succ(int x) { return get_succ_in_tree(root, x); }     inline int pred(int x) { return get_pred_in_tree(root, x); }     inline int ask_kth(int x) { return ask_kth_in_tree(root, x); }     inline int ask_rank(int x) { return ask_rank_in_tree(root, x); }   } T;   int main() {     srand(time(0));     n = read();     for (int i = 1; i <= n; i++) T.insert(i);     ans[1] = 1;     for (int i = 1; i <= n; i++) {       p[i] = read();       T.del(p[i]);       ans[i + 1] = max(0, (T.ask_kth(n - i) - n + i)) + 1;     }     for (int i = 1; i <= n + 1; i++) printf( %d  , ans[i]);   }   