#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2000 * 1000 * 1000;
const double EPS = 1e-9;
const double pi = acos(-1.0);
const int maxn = 100010;
inline long long sqr(int n) { return n * 1ll * n; }
struct Point {
  int x, y;
  Point() {}
  inline bool operator<(const Point& p) const { return y < p.y; }
  inline long long dist_to(const Point& p) const {
    return sqr(x - p.x) + sqr(y - p.y);
  }
};
Point a[maxn];
int n, x, sum;
long long minans = INF * 1ll * INF;
inline void update(const Point& p1, const Point& p2) {
  minans = min(minans, p1.dist_to(p2));
}
inline void go(int l, int r) {
  if (r - l <= 3) {
    for (int i = l; i <= r; i++)
      for (int j = i + 1; j <= r; j++) update(a[i], a[j]);
    sort(a + l, a + r + 1);
    return;
  }
  int mid = (l + r) >> 1;
  int midx = a[mid].x;
  int buf_size = 0;
  go(l, mid - 1);
  go(mid, r);
  static Point buf[maxn];
  merge(a + l, a + mid, a + mid, a + r + 1, buf);
  copy(buf, buf + (r - l + 1), a + l);
  for (int i = l; i <= r; i++) {
    if (sqr(abs(a[i].x - midx)) < minans) {
      for (int j = buf_size - 1; j >= 0 && sqr(a[i].y - buf[j].y) < minans; j--)
        update(a[i], buf[j]);
      buf[buf_size++] = a[i];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    sum += x;
    a[i].x = i + 1;
    a[i].y = sum;
  }
  go(0, n - 1);
  printf("%I64d", minans);
  return 0;
}
