include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 100000 + 10;
const int INF = 1e9 + 7;
ll x[maxn], y[maxn];
int main()
{
int n, tmp;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%d", &tmp), x[i] = (ll)i * i, y[i] = (ll)tmp * tmp;
ll ans = 0;
for(int i = 0; i < 4; i++)
{
ll Max = -1e18, Min = 1e18, tmp;
for(int j = 1; j <= n; j++)
{
if(i == 0)tmp = x[j] + y[j];
else if(i == 1)tmp = x[j] - y[j];
else if(i == 2)tmp = -x[j] + y[j];
else tmp = -x[j] - y[j];
Max = max(Max, tmp);
Min = min(Min, tmp);
}
ans = max(ans, Max - Min);
}
printf("%lld\n", ans);
return 0;
}