#include "bits/stdc++.h" using namespace std; int main(){ int N,ans=0; cin >> N; vector A(N); int sum = 0; for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } int target = (int)sqrt(sum + 0.1);//誤差なくす。 for (int i = 0; i < N; i++) { ans += max(0, A[i] - target - abs((target - 1) - i)); } cout << ans << endl; }