#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 69;
int n;
pair<double, double> a[maxn];
double res = 1e18;
bool cmp(pair<double, double> a, pair<double, double> b) {
  return a.second < b.second;
}
double sqr(double a) { return a * a; }
void dis(pair<double, double> a, pair<double, double> b) {
  double temp = sqr(a.first - b.first) + sqr(a.second - b.second);
  res = min(res, temp);
}
void tinh(int l, int r) {
  if (l == r) return;
  int m = (l + r) / 2;
  tinh(l, m);
  tinh(m + 1, r);
  vector<pair<double, double> > temp;
  for (int i = (l); i <= (r); i++) {
    if (sqr(a[i].first - a[m].first) < res) temp.push_back(a[i]);
  }
  sort(temp.begin(), temp.end(), cmp);
  for (int i = (0); i < (temp.size()); i++) {
    for (int j = (i + 1); j < (temp.size()); j++) {
      if (sqr(temp[j].second - temp[i].second) > res) break;
      dis(temp[i], temp[j]);
    }
  }
}
int okk, sum;
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    cin >> okk;
    sum += okk;
    a[i].first = i, a[i].second = sum;
  }
  sort(a + 1, a + n + 1);
  tinh(1, n);
  cout << fixed << setprecision(0);
  cout << res;
  return 0;
}
