#include <bits/stdc++.h>
using namespace std;
int n;
pair<double, double> A[100010];
bool compare_y(pair<double, double> a, pair<double, double> b) {
  return a.second < b.second;
}
int closest_pair(pair<double, double> *a, int n) {
  if (n <= 1) return 1000000000;
  int m = n / 2;
  double x = a[m].first;
  int d = min(closest_pair(a, m), closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, compare_y);
  vector<pair<double, double> > b;
  for (int i = 0; i < n; i++) {
    if (fabs(a[i].first - x) >= sqrt(d)) continue;
    for (int j = 0; j < b.size(); j++) {
      double dx = a[i].first - b[b.size() - j - 1].first;
      double dy = a[i].second - b[b.size() - j - 1].second;
      if (dy >= sqrt(d)) break;
      d = min(d, (int)(dx * dx + dy * dy));
    }
    b.push_back(a[i]);
  }
  return d;
}
int solve() {
  sort(A, A + n);
  return closest_pair(A, n);
}
int main() {
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    sum += x;
    A[i - 1].first = (double)i;
    A[i - 1].second = (double)sum;
  }
  printf("%d", solve());
  return 0;
}
