func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, a[100000], outpalsz, inn, b[100000];   long long result;   int inicount[100001], iniodd;   int ccount[100001], codd;   int main() {     cin.sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n - 1 - i && a[i] == a[n - 1 - i]; i++) outpalsz++;     for (int i = outpalsz; i < n - outpalsz; i++) {       inicount[a[i]]++;       if (inicount[a[i]] % 2)         iniodd++;       else         iniodd--;       b[inn++] = a[i];     }     if (inn <= 1) {       cout << 1LL * n * (n + 1) / 2 <<   n ;       return 0;     }     if (iniodd <= 1) result = 1LL * (outpalsz + 1) * (outpalsz + 1);     for (int i = 0; i <= 100000; i++) ccount[i] = inicount[i];     codd = iniodd;     for (int i = 0; i < inn; i++) {       ccount[b[i]] -= 2;       if (i * 2 + 1 == inn) ccount[b[i]]++;       if (i > inn - 1 - i && b[i] == b[inn - 1 - i]) ccount[b[i]] += 2;       if (ccount[b[i]] < 0) break;       if (codd <= 1) result += outpalsz + 1;     }     for (int i = 0; i <= 100000; i++) ccount[i] = inicount[i];     codd = iniodd;     for (int i = inn - 1; i >= 0; i--) {       ccount[b[i]] -= 2;       if (i * 2 + 1 == inn) ccount[b[i]]++;       if (i < inn - 1 - i && b[i] == b[inn - 1 - i]) ccount[b[i]] += 2;       if (ccount[b[i]] < 0) break;       if (codd <= 1) result += outpalsz + 1;     }     cout << result <<   n ;     return 0;   }   