#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2e5;
const long long inf = 1e15;
inline int read() {
  char ch = getchar();
  int f = 1, x = 0;
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct Point {
  long long x, y;
  Point() : x(0), y(0) {}
  Point(long long X, long long Y) : x(X), y(Y) {}
  inline long long Len() { return x * x + y * y; }
};
bool operator<(Point a, Point b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }
inline long long Dis(Point a, Point b) {
  return Point(a.x - b.x, a.y - b.y).Len();
}
int n;
long long ans = 1e15, sum[Maxn + 5];
Point P[Maxn + 5], st[Maxn + 5];
inline long long Divide(int l, int r) {
  int mid = (l + r) >> 1, i, j, tot = 0;
  if (l == r) return inf;
  long long d;
  Point pnt = P[mid];
  d = min(Divide(l, mid), Divide(mid + 1, r));
  i = l, j = mid + 1;
  while (i <= mid && j <= r) {
    if (P[i].y < P[j].y)
      st[++tot] = P[i++];
    else
      st[++tot] = P[j++];
  }
  while (i <= mid) st[++tot] = P[i++];
  while (j <= r) st[++tot] = P[j++];
  for (int i = l; i <= r; ++i) P[i] = st[i - l + 1];
  tot = 0;
  for (int i = l; i <= r; ++i)
    if ((pnt.x - P[i].x) * (pnt.x - P[i].x) < d) st[++tot] = P[i];
  for (int i = 1; i <= tot; ++i)
    for (int j = i + 1;
         (st[j].y - st[i].y) * (st[j].y - st[i].y) < d && j <= tot; ++j)
      d = min(d, Dis(st[i], st[j]));
  return d;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + read();
  for (int i = 1; i <= n; ++i) P[i] = Point(i, sum[i]);
  sort(P + 1, P + n + 1);
  ans = Divide(1, n);
  printf("%lld\n", ans);
  return 0;
}
