func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int n;     cin >> n;     vector<int> a(n + 1), b(n + 1), p(n + 1);     for (int i = 1; i <= n; ++i) {       cin >> a[i];       p[a[i]] = 0;     }     for (int i = 1; i <= n; ++i) {       cin >> b[i];       p[b[i]] = i;     }     if (p[1]) {       int k = 1, i;       for (i = 2; p[i] == p[1] + i - 1; ++i) {         k++;       }       if (p[i - 1] == n) {         set<int> s;         for (auto x : a) {           if (x) {             s.insert(x);           }         }         int f = 1;         int ind = 1;         for (; i <= n; ++i) {           auto it = s.find(i);           if (it == s.end()) {             f = 0;             break;           }           s.erase(it);           s.insert(b[ind]);           ind++;         }         if (f == 1) {           cout << n - k;           return 0;         }       }     }     int ans = 0;     for (int i = 1; i <= n; ++i) {       ans = max(ans, p[i] - i + 1 + n);     }     cout << ans;   }   