#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1);
const long long INFF = 1e18;
const int INF = 1e9;
const int mod = 1e9 + 7;
const int MAX = 1e5 + 7;
int n;
long long a[MAX];
long long d = INFF;
pair<long long, long long> pt[MAX];
void init() {
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i) scanf("%lld", a + i);
  for (int i = (1); i < (n + 1); ++i) {
    if (i != 1) d = min(d, a[i] * a[i] + 1);
    a[i] += a[i - 1];
    pt[i] = make_pair(i, a[i]);
  }
  return;
}
inline long long dis(int p1, int p2) {
  return (pt[p1].first - pt[p2].first) * (pt[p1].first - pt[p2].first) +
         (pt[p1].second - pt[p2].second) * (pt[p1].second - pt[p2].second);
}
pair<long long, long long> buf[MAX];
bool cmp(pair<long long, long long>& u, pair<long long, long long>& v) {
  return u.second < v.second;
}
void go(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  go(l, mid);
  go(mid + 1, r);
  int num = 0;
  for (int i = mid; i >= l; --i) {
    if (mid - i >= d) break;
    buf[++num] = pt[i];
  }
  for (int i = mid + 1; i <= r; ++i) {
    if (i - mid >= d) break;
    buf[++num] = pt[i];
  }
  sort(buf + 1, buf + num + 1, cmp);
  for (int i = (1); i < (num + 1); ++i)
    for (int j = (1); j < (4); ++j) {
      if (i + j > num) break;
      d = min(d, dis(buf[i].first, buf[i + j].first));
    }
  return;
}
void sol() {
  go(1, n);
  printf("%lld\n", d);
}
int main(void) {
  init();
  sol();
  return 0;
}
