func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxx = 1e5 + 7;   const int Inf = 1 << 30;   const long long INF = 1ll << 60;   int n;   int a[maxx];   vector<int> vec;   int pos[maxx];   map<int, int> mp;   int ans;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     int cnt = 0;     int t = 0;     bool flg = 0;     for (int i = 1; i <= n; i++) {       if (a[i] == 1) {         if (!flg) pos[++t] = i;         flg = 1;         cnt++;       } else {         if (cnt) vec.push_back(cnt);         cnt = 0;         flg = 0;       }       if (i == n && a[i] == 1) vec.push_back(cnt);     }     for (int i = 0; i < vec.size(); i++) mp[pos[i + 1]] = vec[i];     int pp = pos[1] - 1;     int minx = min(pp, mp[pos[1]]);     ans = max(ans, 2 * minx);     for (int i = 1; i <= t; i++) {       int tmp;       if (i == 1)         tmp = minx;       else         tmp = pos[i] - (pos[i - 1] + mp[pos[i - 1]]);       int min1 = min(tmp, mp[pos[i]]);       int min2 = min(tmp, mp[pos[i - 1]]);       int minT = max(min1, min2);       ans = max(ans, 2 * minT);     }     int dd = n - (pos[t] + mp[pos[t]] - 1);     int min0 = min(dd, mp[pos[t]]);     ans = max(ans, 2 * min0);     cout << ans << endl;   }   