func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MAXN = 100005;   const int D = 1005;   struct data {     int ind;     long long Sum;     data(int _ind, long long _Sum) {       ind = _ind;       Sum = _Sum;     }   };   bool compare(data A, data B) {     if (A.Sum < B.Sum) return true;     if (A.Sum == B.Sum && A.ind < B.ind) return true;     return false;   }   long long f(long long a, long long b, long long c) {     return (((a - b) * (a - b)) + (c * c));   }   long long a[MAXN], S[MAXN];   vector<data> Q;   int main() {     int N;     cin >> N;     S[0] = 0;     for (int i = 1; i <= N; i++) {       cin >> a[i];       S[i] = S[i - 1] + a[i];       data r(i, S[i]);       Q.push_back(r);     }     long long ans = MAXN * MAXN;     for (long long i = 2; i <= N; i++) {       for (long long j = i; j <= i + D && j <= N; j++) {         long long res = f(S[i - 1], S[j], j - i + 1);         ans = min(ans, res);       }     }     sort(Q.begin(), Q.end(), compare);     for (int i = 0; i < Q.size(); i++) {       for (int j = i + 1; j < Q.size() && j < i + D; j++) {         ans = min(ans, f(Q[i].Sum, Q[j].Sum, abs(Q[i].ind - Q[j].ind)));       }     }     cout << ans << endl;     return 0;   }   