func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int mod = 1e9 + 7;   int n, a[N];   long long ans;   map<long long, int> cnt;   void go(long long pos) {     cnt[pos]++;     if (cnt[pos] == 2) {       cnt[pos] = 0;       go(pos + 1);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       go(a[i]);     }     for (auto i : cnt) ans = i.first;     ans++;     for (auto i : cnt)       if (i.second == 1) ans--;     cout << ans;     return 0;   }   