func_code_string: #include <bits/stdc++.h>   using namespace std;   int tree[262192];   int a[262192], pre[262192], ok[262192];   int n;   void check() {     int i, all_1 = 1;     for (i = 1; i <= n; ++i) {       if (a[i] != 1) all_1 = 0;     }     if (all_1) {       printf( 1 n );       exit(0);     }   }   void update(int pt, int l, int r, int index, int val) {     if (l > r || pt < l || pt > r) return;     if (l == r) {       tree[index] = max(tree[index], val);       return;     }     if (pt <= ((l + r) >> 1)) {       update(pt, l, ((l + r) >> 1), (index << 1), val);     } else {       update(pt, ((l + r) >> 1) + 1, r, (index << 1 | 1), val);     }     tree[index] = min(tree[(index << 1)], tree[(index << 1 | 1)]);   }   int query(int start, int end, int l, int r, int index) {     if (start > end || l > r || start > r || l > end) return 0;     if (start <= l && r <= end) return tree[index];     if (end <= ((l + r) >> 1))       return query(start, end, l, ((l + r) >> 1), (index << 1));     if (start >= ((l + r) >> 1) + 1)       return query(start, end, ((l + r) >> 1) + 1, r, (index << 1 | 1));     return min(query(start, end, l, ((l + r) >> 1), (index << 1)),                query(start, end, ((l + r) >> 1) + 1, r, (index << 1 | 1)));   }   int main() {     int i;     scanf( %d , &n);     for (i = 1; i <= n; ++i) scanf( %d , &a[i]);     check();     for (i = 1; i <= n; ++i) {       if (query(1, a[i] - 1, 1, n, 1) > pre[a[i]]) {         ok[a[i]] = 1;       }       pre[a[i]] = i;       update(a[i], 1, n, 1, i);     }     for (i = 1; i <= n; ++i) {       if (query(1, i, 1, n, 1) > pre[i + 1]) {         ok[i + 1] = 1;       }     }     for (i = 2; i <= n + 2; ++i) {       if (!ok[i]) {         printf( %d n , i);         break;       }     }     return 0;   }   