#include <bits/stdc++.h>
int n;
double ans = 1e100;
struct point {
  double x, y;
} pts[100010];
bool operator<(const point &a, const point &b) {
  return a.x < b.x || a.x == b.x && a.y < b.y;
}
double min(double a, double b) { return a < b ? a : b; }
double dis(int a, int b) {
  return (pts[a].x - pts[b].x) * (pts[a].x - pts[b].x) +
         (pts[a].y - pts[b].y) * (pts[a].y - pts[b].y);
}
int main() {
  int i, j, x, sum;
  double SIN = sin(19961126), COS = cos(19961126);
  scanf("%d", &n);
  for (i = 1, sum = 0; i <= n; i++) {
    scanf("%d", &x);
    sum += x;
    pts[i].x = i * COS - sum * SIN;
    pts[i].y = i * SIN + sum * COS;
  }
  std::sort(pts + 1, pts + 1 + n);
  for (i = 1; i <= n; i++)
    for (j = i + 7 > n ? n : i + 7; j > i; j--) ans = min(ans, dis(i, j));
  printf("%I64d", (long long)(ans + 0.5));
  return 0;
}
