#include <bits/stdc++.h>
using namespace std;
int sum = 0;
int temp[100100];
const long long INF = 1LL << 60;
vector<pair<long long, long long> > v;
long long dis2(int p, int q) {
  return ((v[p].first - v[q].first) * (v[p].first - v[q].first)) +
         ((v[p].second - v[q].second) * (v[p].second - v[q].second));
}
bool cmpxy(const pair<long long, long long>& a,
           const pair<long long, long long>& b) {
  if (a.first != b.first) return a.first < b.first;
  return a.second < b.second;
}
bool cmpy(const int& a, const int& b) { return v[a].second < v[b].second; }
long long closest_pair(int p, int q) {
  if (p == q) return INF;
  if (p == q - 1) return dis2(p, q);
  int m = (p + q) >> 1;
  long long d1 = closest_pair(p, m);
  long long d2 = closest_pair(m + 1, q);
  long long d = min(d1, d2);
  int i, j, k = 0;
  for (i = p; i <= q; i++) {
    if (((v[m].first - v[i].first) * (v[m].first - v[i].first)) <= d)
      temp[k++] = i;
  }
  sort(temp, temp + k, cmpy);
  for (i = 0; i < k; i++) {
    for (j = i + 1; j < k && ((v[temp[j]].second - v[temp[i]].second) *
                              (v[temp[j]].second - v[temp[i]].second)) < d;
         j++) {
      long long d3 = dis2(temp[i], temp[j]);
      d = min(d, d3);
    }
  }
  return d;
}
int main() {
  int n;
  cin >> n;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x;
    sum += x;
    v.push_back(make_pair(i + 1, sum));
  }
  cout << closest_pair(0, n - 1) << endl;
  return 0;
}
