func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<long long> b, c;   long long s[1000000];   long long d[1000000];   int F(long long x) {     vector<long long> a = b;     a.push_back(x);     sort(a.rbegin(), a.rend());     long long n = a.size();     s[0] = 0;     for (int i = 1; i <= n; ++i) {       s[i] = s[i - 1] + a[i - 1];       d[i] = -1;     }     int y = 1;     int pos = a.size() - 1;     while (pos >= 0 && y <= n) {       if (a[pos] > y && pos + 1 > y) {         d[y] = pos + 1;         ++y;         continue;       }       --pos;     }     for (long long i = 1; i <= n; ++i) {       if (d[i] == -1) {         d[i] = s[n] - s[i];         continue;       }       d[i] = (d[i] - i) * i + s[n] - s[d[i]];     }     if (s[n] > n * (n - 1)) {       return -1;     }     for (long long k = 1; k < n; ++k) {       if (s[k] > k * (k - 1) + d[k]) {         if (a[k - 1] > x) {           return -1;         }         return 1;       }     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     int n;     cin >> n;     int t = 0;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       b.push_back(x);       t += x;       t %= 2;     }     for (int i = 0; i <= n + 2; ++i) {       if (i % 2 == t) {         c.push_back(i);       }     }     int l = -1;     int r = c.size();     int pos = -1;     while (r - l > 1) {       int m = (l + r) / 2;       if (F(c[m]) == 1) {         r = m;         continue;       }       if (F(c[m]) == -1) {         l = m;         continue;       }       pos = m;       break;     }     if (pos == -1) {       cout << -1;       return 0;     }     l = -1;     r = pos + 1;     while (r - l > 1) {       int m = (l + r) / 2;       if (F(c[m]) == 0) {         r = m;       } else {         l = m;       }     }     int pos1 = r;     l = pos - 1;     r = c.size();     while (r - l > 1) {       int m = (l + r) / 2;       if (F(c[m]) == 0) {         l = m;       } else {         r = m;       }     }     for (int i = pos1; i <= l; ++i) {       cout << c[i] <<    ;     }     return 0;   }   