#include <bits/stdc++.h>
using namespace std;
long long int n, a[100005], su = 0;
long long int sq(long long int x) { return x * x; }
long long int go(int l, int r) {
  if (r == l + 1) return sq(a[r] - a[l]) + 1;
  int mid = (l + r) / 2;
  long long int dm = min(go(l, mid), go(mid, r));
  long long int dmm = (long long int)sqrt(dm) + 5;
  dmm /= 2;
  int left = max((long long int)l, mid - dmm);
  int right = min((long long int)r, mid + dmm);
  vector<pair<long long int, long long int> > v;
  for (int i = left; i <= right; i++) v.push_back(make_pair(a[i], i));
  sort(v.begin(), v.end());
  int sz = v.size();
  for (int i = 0; i < sz; i++)
    for (int j = i + 1; j < sz and v[j].first - v[i].first <= dmm; j++)
      dm = min(dm, sq(v[i].second - v[j].second) + sq(v[i].first - v[j].first));
  return dm;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> a[i];
    su += a[i];
    if (i) a[i] += a[i - 1];
  }
  cout << go(0, n - 1);
  return 0;
}
