#include <bits/stdc++.h>
using namespace std;
struct Node {
  int x;
  long long y;
} node[100001];
bool cmp1(const Node &lhs, const Node &rhs) { return lhs.x < rhs.x; }
bool cmp2(const Node &lhs, const Node &rhs) { return lhs.y < rhs.y; }
long long cal(int s1, int s2) {
  long long x1 = node[s1].x - node[s2].x, x2 = node[s1].y - node[s2].y;
  return x1 * x1 + x2 * x2;
}
long long merge(int l, int r, long long m, double cut) {
  int mid = l + r >> 1;
  int i1 = l, i2 = mid + 1, i3 = 0;
  Node *temp = new Node[r - l + 1];
  while (i1 <= mid && i2 <= r)
    if (node[i1].y < node[i2].y)
      temp[i3++] = node[i1++];
    else
      temp[i3++] = node[i2++];
  while (i1 <= mid) temp[i3++] = node[i1++];
  while (i2 <= r) temp[i3++] = node[i2++];
  for (int i = l; i <= r; i++) node[i] = temp[i - l];
  delete[] temp;
  int *can = new int[r - l + 1], cani = 0;
  for (int i = l; i <= r; i++)
    if (abs((double)node[i].x - cut) < m) can[cani++] = i;
  for (int i = 0; i < cani; i++)
    for (int j = i + 1; j < min(i + 7, cani); j++)
      m = min(m, cal(can[i], can[j]));
  return m;
}
long long divide(int l, int r) {
  if (r - l == 1) return cal(l, r);
  if (r - l == 2) return min(cal(l, l + 1), min(cal(l + 1, r), cal(l, r)));
  if (l < r) {
    int mid = l + r >> 1;
    double cut = node[l + r >> 1].x;
    if ((r - l) & 1) cut += node[(l + r >> 1) + 1].x, cut /= 2;
    return merge(l, r, min(divide(l, mid), divide(mid + 1, r)), cut);
  }
}
int main() {
  int n, tt;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tt);
    node[i].x = i, node[i].y = node[i - 1].y + tt;
  }
  printf("%I64d\n", divide(1, n));
  return 0;
}
