#include <bits/stdc++.h>
using namespace std;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int maxn = 100005;
const int dirs[9][2] = {
    1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 1, 1, 1, -1, -1, 1, -1, -1,
};
long long xt[maxn], yt[maxn], x[maxn], y[maxn];
namespace std {
template <>
struct hash<pair<long long, long long> > {
  size_t operator()(pair<long long, long long> x) const {
    return (abs(x.first) + 1LL) * (abs(x.second) + 1LL);
  }
};
}  // namespace std
unordered_map<pair<long long, long long>, int> h;
pair<long long, long long> gr(int i, long double r) {
  return make_pair(floor((long double)x[i] / r), floor((long double)y[i] / r));
}
void rebuild(int m, long long r2) {
  long double r = sqrt(r2);
  h.clear();
  for (int i = 1; i <= m; i++) h[gr(i, r / 2.0)] = i;
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  int p[maxn];
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    xt[i] = i;
    yt[i] = yt[i - 1] + t;
    p[i] = i;
  }
  random_shuffle(p + 1, p + 1 + n);
  random_shuffle(p + 1, p + 1 + n);
  for (int i = 1; i <= n; i++) x[i] = xt[p[i]], y[i] = yt[p[i]];
  long long r2 = 1e18 * 1.5;
  rebuild(1, r2);
  for (int i = 2; i <= n; i++) {
    long double r = sqrt(r2);
    pair<long long, long long> curr = gr(i, r / 2.0);
    long long cr = r2;
    for (int ddx = -2; ddx <= 2; ddx++)
      for (int ddy = -2; ddy <= 2; ddy++) {
        auto it = h.find(make_pair(curr.first + ddx, curr.second + ddy));
        if (it == h.end()) continue;
        long long dx = x[it->second] - x[i];
        long long dy = y[it->second] - y[i];
        cr = min(cr, dx * dx + dy * dy);
      }
    if (cr < r2) {
      r2 = cr;
      rebuild(i, r2);
    } else {
      h[curr] = i;
    }
  }
  cout << r2 << endl;
  return 0;
}
