#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} p[100008], tmp[100008];
long long dis(node m, node n) {
  return (long long)(m.x - n.x) * (m.x - n.x) +
         (long long)(m.y - n.y) * (m.y - n.y);
}
long long closestpair(int ll, int rr) {
  if (rr - ll <= 1) return 1ll << 60;
  int m = (ll + rr) / 2;
  long long d1 = closestpair(ll, m);
  long long d2 = closestpair(m, rr);
  long long dm = min(d1, d2), dl = 1ll << 60;
  int t1 = ll, t2 = m, i = ll;
  while (t1 < m || t2 < rr) {
    if (t2 >= rr || (t1 < m && p[t1].y <= p[t2].y))
      tmp[i++] = p[t1++];
    else
      tmp[i++] = p[t2++];
  }
  for (i = ll; i < rr; i++) p[i] = tmp[i];
  int k = ll, j;
  for (i = ll; i < rr; i++)
    if ((long long)(p[i].x - m) * (p[i].x - m) < dm) tmp[k++] = p[i];
  for (i = ll; i < k; i++)
    for (j = i + 1;
         j < k && (long long)(tmp[j].y - tmp[i].y) * (tmp[j].y - tmp[i].y) < dm;
         j++)
      dl = min(dl, dis(tmp[i], tmp[j]));
  return min(dm, dl);
}
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &p[i].y);
    p[i].x = i;
    if (i > 0) p[i].y += p[i - 1].y;
  }
  printf("%I64d", closestpair(0, n));
  return 0;
}
