#include <bits/stdc++.h>
using namespace std;
long long sum[100005];
const long long INF = 10000000000000;
struct point {
  long long x;
  long long y;
} p[100005], p1[100005];
long long sqr(long long x) { return x * x; }
bool cmp(point a, point b) { return a.y < b.y; }
long long solve(long long l, long long r) {
  if (l == r) return INF;
  long long mid = (l + r) / 2;
  long long d1 = solve(l, mid);
  long long d2 = solve(mid + 1, r);
  long long d = min(d1, d2);
  int k = 0;
  long long t = p[mid].x;
  for (int i = l; i <= r; i++)
    if (sqr(t - p[i].x) <= d) p1[k++] = p[i];
  sort(p1, p1 + k, cmp);
  for (int i = 0; i < k; i++) {
    int Y = p1[i].y;
    for (int j = i + 1; j < k; j++)
      if (sqr(Y - p1[j].y) > d)
        break;
      else
        d = min(d, sqr(p1[i].x - p1[j].x) + sqr(p1[i].y - p1[j].y));
  }
  return d;
}
int main() {
  long long n;
  while (scanf("%I64d", &n) == 1) {
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
      long long x;
      scanf("%I64d", &x);
      sum[i] = sum[i - 1] + x;
      p[i].x = i;
      p[i].y = sum[i];
    }
    printf("%I64d\n", solve(1, n));
  }
  return 0;
}
