#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
long long f(int l, int r) {
  if (l >= r) return 1LL * 1000000007 * 1000000007;
  if (r - l + 1 <= 4) {
    long long ans = 1LL * 1000000007 * 1000000007;
    for (int i = l; i < r + 1; i++) {
      for (int j = i + 1; j < r + 1; j++) {
        ans = min(
            ans, 1LL * (i - j) * (i - j) + 1LL * (a[i] - a[j]) * (a[i] - a[j]));
      }
    }
    return ans;
  }
  int mx = (l + r) / 2;
  long long d = min(f(l, mx), f(mx + 1, r));
  vector<pair<int, int> > strip;
  for (int i = l; i < r + 1; i++) {
    if ((i - mx) * (i - mx) < d) {
      strip.push_back({a[i], i});
    }
  }
  sort((strip).begin(), (strip).end());
  for (int i = 0; i < (int)strip.size(); i++) {
    for (int j = i + 1; j < (int)strip.size(); j++) {
      if ((strip[j].first - strip[i].first) *
              (strip[j].first - strip[i].first) <
          d) {
        d = min(d, 1LL * (strip[j].first - strip[i].first) *
                           (strip[j].first - strip[i].first) +
                       1LL * (strip[j].second - strip[i].second) *
                           (strip[j].second - strip[i].second));
      } else
        break;
    }
  }
  return d;
}
void solve() {
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  cout << f(1, n) << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
