#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int SUM = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    SUM = (SUM << 3) + (SUM << 1) + (ch ^ 48);
    ch = getchar();
  }
  return SUM * ff;
}
const int N = 100010;
struct point {
  long long x, y;
} p[N], tmp[N];
int n;
inline bool cmp(point a1, point a2) { return a1.y < a2.y; }
inline long long dist(point a1, point a2) {
  return (a1.x - a2.x) * (a1.x - a2.x) + (a1.y - a2.y) * (a1.y - a2.y);
}
inline long long solve(int l, int r) {
  if (l == r) return 1ll << 50;
  if (l + 1 == r) return dist(p[l], p[r]);
  int mid = (l + r) >> 1;
  long long dist1 = solve(l, mid), dist2 = solve(mid + 1, r);
  long long d = min(dist1, dist2);
  int k = 0;
  for (int i = l; i <= r; i++)
    if ((p[mid].x - p[i].x) * (p[mid].x - p[i].x) <= d) tmp[++k] = p[i];
  sort(tmp + 1, tmp + k + 1, cmp);
  for (int i = 1; i <= k; i++)
    for (int j = i + 1; j <= k; j++) {
      if ((tmp[i].y - tmp[j].y) * (tmp[i].y - tmp[j].y) > d) break;
      d = min(d, dist(tmp[i], tmp[j]));
    }
  return d;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    p[i].y = p[i - 1].y + read();
    p[i].x = i;
  }
  printf("%lld\n", solve(1, n));
  return 0;
}
