#include <bits/stdc++.h>
using namespace std;
const int MAX = 111111;
struct point {
  int x, y;
};
vector<point> p;
int n;
int read() {
  scanf("%d", &n);
  int x, y, t;
  y = 0;
  for (int i = 0; i < (n); i++) {
    scanf("%d", &t);
    x = i + 1;
    y += t;
    point z;
    z.x = x;
    z.y = y;
    p.push_back(z);
  }
  return 0;
}
int cmpx(point l, point r) { return l.x < r.x; }
int cmpy(point l, point r) { return l.y < r.y; }
long long ans;
int updateAns(point p1, point p2) {
  if (1LL * ((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)) <
      ans)
    ans = 1LL * ((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
  return 0;
}
point t[MAX];
int find(int l, int r) {
  if (r - l <= 2) {
    for (int i = (l); i <= (r); i++)
      for (int j = (i + 1); j <= (r); j++) {
        updateAns(p[i], p[j]);
      }
    sort(p.begin() + l, p.begin() + r + 1, cmpy);
    return 0;
  }
  int m = (l + r) / 2;
  int midx = p[m].x;
  find(l, m);
  find(m + 1, r);
  merge(p.begin() + l, p.begin() + m + 1, p.begin() + m + 1, p.begin() + r + 1,
        t, cmpy);
  copy(t, t + r - l + 1, p.begin() + l);
  int sz = 0;
  for (int i = (l); i <= (r); i++)
    if (1LL * (p[i].x - midx) * (p[i].x - midx) < ans) {
      for (int j = (sz - 1); j >= (0); j--) {
        if (1LL * (p[i].y - t[j].y) * (p[i].y - t[j].y) >= ans) break;
        updateAns(p[i], t[j]);
      }
      t[sz++] = p[i];
    }
  return 0;
}
int process() {
  sort(p.begin(), p.end(), cmpx);
  ans = 1000000000000000000LL;
  find(0, n - 1);
  printf("%I64d\n", ans);
  return 0;
}
int main() {
  read();
  process();
  return 0;
}
