#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using pdd = pair<double, double>;
const int INF = 0x3fffffff;
const LL LINF = 0x3fffffffffffffff;
const double EPS = 1e-9;
const double PI = 2 * asin(1);
const int MX = 100000 + 10;
int g_n;
pdd vpdd[MX];
void pretreat() {}
bool input() {
  cin >> g_n;
  if (cin.eof()) return false;
  LL sum = 0;
  for (int i = 0, t; i < g_n; ++i) {
    scanf(" %d", &t);
    sum += t;
    vpdd[i].first = i;
    vpdd[i].second = sum;
  }
  return true;
}
bool cmp(pdd a, pdd b) { return a.second < b.second; }
double closest_pair(pdd *a, int n) {
  if (n <= 1) return INF;
  int m = n / 2;
  double x = a[m].first;
  double d = min(closest_pair(a, m), closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, cmp);
  vector<pdd> b;
  for (int i = 0; i < n; ++i) {
    if (fabs(a[i].first - x) >= d) continue;
    for (int j = 0; j < b.size(); ++j) {
      double dx = a[i].first - b[b.size() - j - 1].first;
      double dy = a[i].second - b[b.size() - j - 1].second;
      if (dy >= d) break;
      d = min(d, sqrt(dx * dx + dy * dy));
    }
    b.push_back(a[i]);
  }
  return d;
}
void solve() {
  sort(vpdd, vpdd + g_n);
  double ans = closest_pair(vpdd, g_n);
  printf("%.0f\n", ans * ans);
}
int main() {
  pretreat();
  while (input()) {
    solve();
  }
  return 0;
}
