#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const int maxn = 100010;
long long ans = (long long)4e18;
template <typename T>
inline T sqr(const T &a) {
  return a * a;
}
template <typename T1, typename T2>
inline void upto(T1 &a, const T2 &b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
inline void downto(T1 &a, const T2 &b) {
  if (a > b) a = b;
}
struct point {
  long long x, y;
  point() : x(0), y(0) {}
  point(long long x, long long y) : x(x), y(y) {}
};
point v[maxn];
point help[maxn];
typedef bool cmpt(point a, point b);
bool cmpy(point a, point b) {
  if (a.y != b.y) return a.y < b.y;
  return a.x < b.x;
}
bool cmp(point a, point b) { return a.y < b.y; }
bool operator<(point a, point b) { return a.x < b.x; }
void merge(int l1, int r1, int l2, int r2) {
  int pos = l1;
  int it = pos;
  while (l1 <= r1 || l2 <= r2) {
    if (l1 > r1) {
      help[pos] = v[l2];
      l2++;
    } else if (l2 > r2) {
      help[pos] = v[l1];
      l1++;
    } else {
      if (cmp(v[l1], v[l2])) {
        help[pos] = v[l1];
        l1++;
      } else {
        help[pos] = v[l2];
        l2++;
      }
    }
    pos++;
  }
  for (int i = it; i < pos; i++) {
    v[i] = help[i];
  }
}
long long dist(point a, point b) { return sqr(a.x - b.x) + sqr(a.y - b.y); }
long long search(int l, int r) {
  if (l == r) {
    return (long long)4e18;
  }
  int m = (l + r) / 2;
  int vmx = v[m].x;
  long long ans = min(search(l, m), search(m + 1, r));
  inplace_merge(v + l, v + m + 1, v + r + 1, cmp);
  static vector<point> now;
  now.clear();
  for (int i = l; i <= r; i++) {
    if (sqr(v[i].x - vmx) <= ans) {
      now.push_back(v[i]);
    }
  }
  for (int i = 0; i < (int)now.size(); i++) {
    for (int j = i + 1; j < (int)now.size() && sqr(now[i].y - now[j].y) < ans;
         j++) {
      ans = min(ans, dist(now[i], now[j]));
    }
  }
  return ans;
}
void center(int n) {
  int lp = 0;
  typedef set<point, cmpt *> sett;
  sett q(&cmpy);
  for (int i = 0; i < n; i++) {
    while (lp < i && sqr(v[lp].x - v[i].x) >= ans) {
      q.erase(v[lp++]);
    }
    sett::iterator it, it1;
    it = q.lower_bound(v[i]);
    for (it1 = it; it1 != q.end() && sqr(v[i].y - it1->y) < ans; it1++) {
      downto(ans, dist(*it1, v[i]));
    }
    it1 = it;
    if (it1 != q.begin())
      for (it1--; sqr(v[i].y - it1->y) < ans; it1--) {
        downto(ans, dist(*it1, v[i]));
        if (it1 == q.begin()) break;
      }
    q.insert(v[i]);
  }
}
long long a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    if (i != 0) {
      a[i] += a[i - 1];
    }
  }
  for (int i = 0; i < n; i++) {
    v[i] = point((long long)i, a[i]);
  }
  printf("%I64d", search(0, n - 1));
  return 0;
}
