#include <bits/stdc++.h>
template <typename T>
inline bool chkmin(T &a, T b) {
  return b < a ? a = b, true : false;
}
template <typename T>
inline bool chkmax(T &a, T b) {
  return b > a ? a = b, true : false;
}
template <class T>
inline T read(T &x) {
  int sign = 1;
  char c = getchar_unlocked();
  for (; !isdigit(c); c = getchar_unlocked())
    if (c == '-') sign = -1;
  for (x = 0; isdigit(c); c = getchar_unlocked()) x = x * 10 + c - '0';
  return x *= sign;
}
template <class T>
inline void write(T x) {
  if (x == 0) {
    putchar_unlocked('0');
    return;
  }
  if (x < 0) {
    putchar_unlocked('-');
    x = -x;
  }
  static char s[20];
  int top = 0;
  for (; x; x /= 10) s[++top] = x % 10 + '0';
  while (top) putchar_unlocked(s[top--]);
}
const int maxN = 1e5 + 100;
const int inf = 0x3f3f3f3f;
std::pair<int, int> p[maxN];
int a[maxN], sum[maxN];
int n;
inline bool cmpy(const std::pair<int, int> &lhs,
                 const std::pair<int, int> &rhs) {
  return lhs.second < rhs.second;
}
inline long long dist0(std::pair<int, int> a, std::pair<int, int> b) {
  return (a.first - b.first) * (a.first - b.first) +
         (a.second - b.second) * (a.second - b.second);
}
long long solve(int l, int r) {
  if (l == r) return inf;
  if (l + 1 == r) return dist0(p[l], p[r]);
  int mid = (l + r) >> 1;
  long long dist = std::min(solve(l, mid), solve(mid + 1, r));
  int tot = 0;
  static std::pair<int, int> q[maxN];
  for (int i = l; i <= r; ++i)
    if ((long long)(p[i].first - p[mid].first) * (p[i].first - p[mid].first) <
        dist)
      q[++tot] = p[i];
  std::sort(q + 1, q + tot + 1, cmpy);
  for (int i = 1; i <= tot; ++i) {
    for (int j = i + 1; j <= tot; ++j) {
      if ((long long)(q[i].second - q[j].second) * (q[i].second - q[j].second) >
          dist)
        break;
      chkmin(dist, dist0(q[i], q[j]));
    }
  }
  return dist;
}
int main() {
  if (fopen("tmp.in", "r")) {
    freopen("tmp.in", "r", stdin);
    freopen("tmp.out", "w", stdout);
  }
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];
  for (int i = 1; i <= n; ++i) p[i] = std::make_pair(i, sum[i]);
  write(solve(1, n)), putchar_unlocked('\n');
  return 0;
}
