#include <bits/stdc++.h>   using namespace std;   long long n;   struct node {     long long x, y;   } po[100000];   inline long long dis(node a, node b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);   }   bool cmp(const node &a, const node &b) {     return (a.y == b.y ? a.x < b.x : a.y < b.y);   }   long long solve(long long ll, long long rr) {     if (ll == rr) return (long long)2e18;     if (ll + 1 == rr) return dis(po[ll], po[rr]);     if (ll + 2 == rr)       return min(dis(po[ll], po[rr]),                  min(dis(po[ll], po[ll + 1]), dis(po[ll + 1], po[rr])));     long long mid = (ll + rr) >> 1;     long long res = min(solve(ll, mid), solve(mid + 1, rr));     sort(po + ll, po + rr + 1, cmp);     for (long long i = ll; i <= rr; ++i) {       for (long long j = i + 1; j <= rr && j <= i + 8; ++j)         res = min(res, dis(po[i], po[j]));     }     return res;   }   int main() {     scanf( %I64d , &n);     for (long long i = 1; i <= n; ++i)       scanf( %I64d , &po[i].y), po[i].y += po[i - 1].y, po[i].x = i;     printf( %I64d n , solve(1, n));     return 0;   }   