#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000005LL;
bool rev(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second == b.second) return (a.first < b.first);
  return (a.second < b.second);
}
inline long long dist(pair<long long, long long>& A,
                      pair<long long, long long>& B) {
  return ((A.first - B.first) * (A.first - B.first) +
          (A.second - B.second) * (A.second - B.second));
}
long long solve(vector<pair<long long, long long> >& X,
                vector<pair<long long, long long> >& Y) {
  int s = X.size();
  long long naj = INF;
  if (s < 3) {
    for (int i = 0; i < s; ++i)
      for (int j = i + 1; j < s; ++j) naj = min(naj, dist(X[i], X[j]));
    return naj;
  }
  int hf = s / 2;
  vector<pair<long long, long long> > X1, Y1, X2, Y2;
  X1.reserve(hf + 5);
  X2.reserve(hf + 5);
  Y1.reserve(hf + 5);
  Y2.reserve(hf + 5);
  for (int i = 0; i < s; ++i) {
    if (X[i] <= X[hf])
      X1.push_back(X[i]);
    else
      X2.push_back(X[i]);
    if (Y[i] <= X[hf])
      Y1.push_back(Y[i]);
    else
      Y2.push_back(Y[i]);
  }
  naj = min(solve(X1, Y1), solve(X2, Y2));
  int pos = 0;
  for (int i = 0; i < s; ++i)
    if (abs(Y[i].first - X[hf].first) <= naj) Y[pos++] = Y[i];
  s = pos;
  for (int i = 0; i < s; ++i)
    for (int j = 1; j < 10; ++j) {
      if (i + j >= s) break;
      naj = min(naj, dist(Y[i], Y[i + j]));
    }
  return naj;
}
int main() {
  int n;
  scanf("%d", &n);
  long long poprz = 0LL;
  vector<pair<long long, long long> > X, Y;
  for (int i = 1; i <= n; ++i) {
    long long a = i, b;
    scanf("%lld", &b);
    b += poprz;
    poprz = b;
    X.push_back({a, b});
    Y.push_back({a, b});
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end(), rev);
  long long res = solve(X, Y);
  printf("%lld", res);
}
