#include <bits/stdc++.h>
using namespace std;
namespace red {
inline long long read() {
  long long x = 0;
  char ch, f = 1;
  for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') f = 0, ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return f ? x : -x;
}
const long long N = 2e5 + 10, inf = 1ll << 60;
long long n, tmp[N];
struct node {
  long long x, y;
} s[N];
inline bool cmp(const node &a, const node &b) {
  return a.x == b.x ? a.y < b.y : a.x < b.x;
}
inline bool cmps(const long long &a, const long long &b) {
  return s[a].y < s[b].y;
}
inline long long dist(long long i, long long j) {
  return (s[i].x - s[j].x) * (s[i].x - s[j].x) +
         (s[i].y - s[j].y) * (s[i].y - s[j].y);
}
inline long long solve(long long l, long long r) {
  long long d = inf;
  if (l == r) return d;
  if (l + 1 == r) return dist(l, r);
  long long mid = (l + r) >> 1;
  long long d1 = solve(l, mid);
  long long d2 = solve(mid + 1, r);
  d = min(d1, d2);
  long long top = 0;
  for (long long i = l; i <= r; ++i)
    if ((s[mid].x - s[i].x) * (s[mid].x - s[i].x) <= d) tmp[++top] = i;
  sort(tmp + 1, tmp + top + 1, cmps);
  for (long long i = 1; i <= top; ++i)
    for (long long j = i + 1;
         j <= top &&
         (s[tmp[j]].y - s[tmp[i]].y) * (s[tmp[j]].y - s[tmp[i]].y) < d;
         ++j)
      d = min(d, dist(tmp[i], tmp[j]));
  return d;
}
inline void main() {
  n = read();
  for (long long i = 1; i <= n; ++i) {
    s[i].x = i, s[i].y = s[i - 1].y + read();
  }
  printf("%lld\n", solve(1, n));
}
}  // namespace red
signed main() {
  red::main();
  return 0;
}
