func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 10;   int n;   int a[N], indexes[N], parent[N], rrank[N], ccount[N];   bool used[N];   int get_set(int v) {     if (v == parent[v]) return v;     return parent[v] = get_set(parent[v]);   }   void create_set(int v) {     parent[v] = v;     rrank[v] = 0;     ccount[v] = 1;   }   void merge_sets(int v, int u) {     v = get_set(v);     u = get_set(u);     if (v != u) {       if (rrank[v] > rrank[u]) swap(v, u);       parent[v] = u;       if (rrank[v] == rrank[u]) rrank[u]++;       ccount[u] += ccount[v];     }   }   bool comp(int i, int j) { return a[i] < a[j]; }   int solve() {     int maxSize = 0, maxSets, sets = 0;     int res = 0, resSets = -1;     for (int i = 0; i < n; i++) {       bool isMerged = false;       int ind = indexes[i];       used[ind] = true;       sets++;       if (ind > 0 && used[ind - 1]) {         isMerged = true;         merge_sets(ind - 1, ind);         sets--;       }       if (ind < n - 1 && used[ind + 1]) {         isMerged = true;         merge_sets(ind + 1, ind);         sets--;       }       int sst = get_set(ind);       if (ccount[sst] > maxSize) {         maxSize = ccount[sst];         maxSets = 1;       } else if (ccount[sst] == maxSize) {         maxSets++;       }       if (i < n - 1 && a[indexes[i]] == a[indexes[i + 1]]) {         continue;       }       if (maxSets == sets && sets > resSets) {         resSets = sets;         res = a[ind] + 1;       }     }     return res;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       indexes[i] = i;       create_set(i);       used[i] = false;     }     sort(indexes, indexes + n, comp);     cout << solve();     return 0;   }   