#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
long long a[N];
int n;
struct point {
  long long x, y;
} p[N], t[N];
bool cmpy(point a, point b) { return a.y < b.y; }
long long dist(point a, point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
long long solve(int left, int right) {
  long long d = 1e18;
  if (left == right) return d;
  if (left + 1 == right) return dist(p[left], p[right]);
  int mid = (left + right) / 2;
  d = min(solve(left, mid), solve(mid + 1, right));
  int k = 0;
  for (int i = left; i <= right; i++)
    if ((p[i].x - p[mid].x) * (p[i].x - p[mid].x) <= d) t[k++] = p[i];
  sort(t, t + k, cmpy);
  for (int i = 0; i < k; i++)
    for (int j = i + 1; j < k && (t[i].y - t[j].y) * (t[i].y - t[j].y) < d; j++)
      d = min(d, dist(t[i], t[j]));
  return d;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    p[i].x = i;
    p[i].y = p[i - 1].y + a[i];
  }
  printf("%lld\n", solve(1, n));
  return 0;
}
