import java.util.Scanner; public class Main_yukicoder77 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); sum += a[i]; } int nn = (int)Math.sqrt(sum); int p = 0; int m = 0; for (int i = 0; i < n; i++) { int tmp; if (i < nn) { tmp = i + 1; } else { tmp = Math.max(0, nn - (i - nn + 1)); } if (a[i] > tmp) { p += a[i] - tmp; } else { m += tmp - a[i]; } } System.out.println(m + Math.max(0, p - m)); sc.close(); } }