N = int(input()) A = list(map(int,input().split())) M = sum(A) n = 1 while n**2<=M: n += 1 n -= 1 ans = M for k in range(1,n+1): A1 = A+[0 for _ in range(200-N)] B = list(range(1,k+1))+list(range(1,k))[::-1] B1 = B+[0 for _ in range(200-len(B))] cnt = 0 for i in range(200): cnt += max(A1[i]-B1[i],0) ans = min(ans,cnt) print(ans)