#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int inf = 1e17;
const long long int N = 1e5 + 5;
struct Point {
  long long int x, y;
  Point operator-(Point p) { return {x - p.x, y - p.y}; }
  long long int 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 int n, ans = 1e18;
long long int a[N], pref[N];
Point pt[N];
long long int solve(long long int L, long long int R) {
  if (L == R) return 1e18;
  long long int M = (L + R) / 2;
  sort(pt + L, pt + R + 1, by_x);
  long long int d = min(solve(L, M), solve(M + 1, R));
  long long int midx = pt[L + (R - L + 1) / 2].x;
  vector<Point> v;
  for (long long int 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 int i = 0; i < v.size(); i++) {
    for (long long int j = i + 1; j < v.size(); j++) {
      if (Point{0, v[i].y - v[j].y}.dist() > d) break;
      d = min(d, (v[i] - v[j]).dist());
    }
  }
  return d;
}
void __solve() {
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    pref[i] = pref[i - 1] + a[i];
    pt[i] = {i, pref[i]};
  }
  cout << solve(1, n);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) {
    __solve();
    cout << '\n';
  }
}
