#include <bits/stdc++.h>
using namespace std;
struct TPoint {
  long long x, y;
  long id;
};
long n, id1, id2;
long long a[110000], s[110000];
TPoint P[110000], Pt[110000];
double res;
double dist(TPoint A, TPoint B) {
  return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
}
bool compare(TPoint A, TPoint B) {
  if (A.x < B.x) return true;
  return false;
}
bool check(long u, long v) {
  double temp;
  if (u != v) {
    temp = dist(P[u], P[v]);
    if (temp < res - 1e-6) {
      res = temp;
      id1 = P[u].id;
      id2 = P[v].id;
    }
  }
}
void Merge(long k, long L) {
  for (long i = k; i <= L; i++) Pt[i] = P[i];
  long j = (k + L) / 2 + 1, i = k, u = k - 1;
  while (u != L) {
    u++;
    if (i > (k + L) / 2) {
      P[u] = Pt[j];
      j++;
    } else if (j > L) {
      P[u] = Pt[i];
      i++;
    } else {
      if (Pt[i].y <= Pt[j].y) {
        P[u] = Pt[i];
        i++;
      } else {
        P[u] = Pt[j];
        j++;
      }
    }
  }
}
void SortY(long k, long L) {
  long mid;
  double r;
  if (k == L) return;
  mid = (k + L) / 2;
  r = P[mid].x;
  SortY(k, mid);
  SortY(mid + 1, L);
  Merge(k, L);
  long i1 = k, i2 = k, i3 = k, i4 = k;
  for (long i = k + 1; i <= L; i++)
    if (fabs(P[i].x - r) < res - 1e-6) {
      check(i, i1);
      check(i, i2);
      check(i, i3);
      check(i, i4);
      i1 = i2;
      i2 = i3;
      i3 = i4;
      i4 = i;
    }
}
int main() {
  scanf("%ld", &n);
  for (long i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    s[i] = s[i - 1] + a[i];
    P[i].x = i;
    P[i].y = s[i];
    P[i].id = i;
  }
  sort(P + 1, P + n + 1, compare);
  res = 1000000000;
  SortY(1, n);
  res = (res) * (res);
  printf("%.0lf\n", res);
  return 0;
}
