#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;
const int MXN = (int)1e5 + 7;
int n;
int a[MXN], s[MXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
  }
  long long ans = a[2] * a[2] + 1;
  for (int dl = 1; dl < n; ++dl) {
    if ((long long)dl * dl >= ans) break;
    for (int l = 1; l <= n - dl; l++) {
      ans = min(ans, (long long)dl * dl +
                         (long long)(s[l + dl] - s[l]) * (s[l + dl] - s[l]));
    }
  }
  cout << ans;
  return 0;
}
