#include <bits/stdc++.h>
using namespace std;
const long long INF = 4e18 + 10;
inline long long sqr(long long first) { return first * first; }
inline long long dist(pair<long long, long long> a,
                      pair<long long, long long> b) {
  return sqr(a.first - b.first) + sqr(a.second - b.second);
}
vector<pair<long long, long long> > v;
vector<pair<long long, long long> > tmp;
long long close(int l, int r) {
  long long d = INF;
  if (l == r) return d;
  if (r - l == 1) return dist(v[l], v[r]);
  int m = (l + r) >> 1;
  d = min(close(l, m), close(m + 1, r));
  tmp.clear();
  for (int i = l; i <= r; i++)
    if (sqr(v[i].first - v[m].first) <= d) tmp.push_back(v[i]);
  sort(tmp.begin(), tmp.end(),
       [](pair<long long, long long> a, pair<long long, long long> b) -> bool {
         return a.second < b.second;
       });
  for (int i = 0; i < tmp.size(); i++)
    for (int k = i - 1; k >= 0 && sqr(tmp[i].second - tmp[k].second) <= d; k--)
      d = min(d, dist(tmp[i], tmp[k]));
  return d;
}
int main() {
  int n;
  scanf("%d", &n);
  long long a;
  long long sum = 0;
  for (long long i = 0; i < (long long)n; i++) {
    scanf("%lld", &a);
    sum += a;
    v.push_back({i, sum});
  }
  printf("%lld\n", close(0, n - 1));
}
