#include <bits/stdc++.h>
using namespace std;
long long read_ll() {
  char c;
  long long res = 0;
  bool check = 0;
  while (1) {
    c = getchar();
    if (c == '-') {
      check = 1;
      continue;
    }
    if (c == ' ' || c == '\n') break;
    res = res * 10ll + (long long)c - '0';
  }
  if (check) return -res;
  return res;
}
struct point {
  long long x, y;
  point(long long x = 0.0, long long y = 0.0) : x(x), y(y) {}
};
bool cmp(point x, point y) { return x.y < y.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 n, tmp;
vector<point> a, b;
long long solve(long long l, long long r) {
  if (l == r) return (1ll << 60);
  if (l == r - 1) return dist(a[l], a[r]);
  long long mid = (l + r) / 2;
  long long d0 = min(solve(l, mid), solve(mid + 1, r));
  long long L = (1ll << 60), R = -(1ll << 60);
  b.clear();
  for (long long i = l; i <= r; i++)
    if (a[mid].x - d0 <= a[i].x && a[i].x <= a[mid].x + d0) b.push_back(a[i]);
  sort(b.begin(), b.end(), cmp);
  for (long long i = 0; i < (long long)b.size(); i++) {
    for (long long j = i + 1; j < min((long long)b.size(), i + 5); j++)
      d0 = min(d0, dist(b[i], b[j]));
  }
  return d0;
}
int main() {
  n = read_ll();
  for (long long i = 1; i <= n; i++)
    tmp += read_ll(), a.push_back(point(i, tmp));
  printf("%lld", solve(0, n - 1));
}
