#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y, id;
  Point operator-(Point p) { return {x - p.x, y - p.y}; }
  long long dist() { return x * x + y * y; }
};
bool by_x(Point &a, Point &b) { return a.x < b.x; }
bool by_y(Point &a, Point &b) { return a.y < b.y; }
long long n, ans = 1LL << 60;
long long a[100010], pref[100010];
Point pt[100010];
long long solve(long long L, long long R, long long &aa, long long &bb) {
  if (L == R) {
    aa = L;
    bb = R;
    return 1LL << 60;
  }
  long long M = (L + R) / 2;
  sort(pt + L, pt + R + 1, by_x);
  long long a1, a2, b1, b2, ans1, ans2, d;
  ans1 = solve(L, M, a1, b1);
  ans2 = solve(M + 1, R, a2, b2);
  if (ans1 < ans2) {
    d = ans1;
    aa = a1;
    bb = b1;
  } else {
    d = ans2;
    aa = a2;
    bb = b2;
  }
  long long midx = pt[L + (R - L + 1) / 2].x;
  vector<Point> v;
  for (long long i = L; i <= R; i++) {
    if (Point{pt[i].x - midx, 0}.dist() < d) {
      v.push_back(pt[i]);
    }
  }
  sort(v.begin(), v.end(), by_y);
  for (long long i = 0; i < v.size(); i++) {
    for (long long j = i + 1; j < v.size(); j++) {
      if (Point{0, v[i].y - v[j].y}.dist() > d) break;
      ans1 = (v[i] - v[j]).dist();
      if (ans1 < d) {
        d = ans1;
        aa = v[i].id;
        bb = v[j].id;
      }
    }
  }
  return d;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, k, x, y, aa, bb, ans;
  cin >> n;
  vector<long long> a(n + 1), s(n + 1);
  s[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  for (i = 0; i < n; i++) {
    pt[i].x = i;
    pt[i].y = s[i + 1];
    pt[i].id = i + 1;
  }
  ans = solve(0, n - 1, aa, bb);
  cout << ans << "\n";
  return 0;
}
