#include <bits/stdc++.h>
using namespace std;
struct pt {
  long long id, x, y;
  pt() {}
  pt(long long x, long long y, long long id = 0) : id(id), x(x), y(y) {}
};
bool by_x(pt a, pt b) { return a.x < b.x; }
bool by_y(pt a, pt b) { return a.y < b.y; }
class closest_pair {
 public:
  pt p[100001], t[100001];
  long long p1, p2, d2;
  void update_ans(pt a, pt b) {
    long long nd = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
    if (nd < d2) {
      d2 = nd;
      p1 = min(a.id, b.id);
      p2 = max(a.id, b.id);
    }
  }
  void solve(int l, int r) {
    if (r - l < 4) {
      for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++) update_ans(p[i], p[j]);
      sort(p + l, p + r + 1, by_y);
      return;
    }
    int m = (l + r) / 2, c = 0, mx = p[m].x;
    solve(l, m);
    solve(m + 1, r);
    merge(p + l, p + m + 1, p + m + 1, p + r + 1, t, by_y);
    copy(t, t + r - l + 1, p + l);
    for (int i = l; i <= r; i++)
      if ((p[i].x - mx) * (p[i].x - mx) < d2) {
        for (int j = c - 1;
             j >= 0 && (p[i].y - t[j].y) * (p[i].y - t[j].y) < d2; j--)
          update_ans(p[i], t[j]);
        t[c++] = p[i];
      }
  }
  void solve(int n) {
    p1 = p2 = 0;
    d2 = 4e18;
    sort(p + 1, p + n + 1, by_x);
    solve(1, n);
  }
} cp;
long long n, a, s = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    s += a;
    cp.p[i] = pt(i, s);
  }
  cp.solve(n);
  cout << cp.d2;
  return 0;
}
