import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static final int MAX = 1000; public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); int[] arr = new int[MAX]; for(int i = 0; i < N; i++){ arr[i] = sc.nextInt(); } final int sum = Arrays.stream(arr).sum(); int diff = Integer.MAX_VALUE; for(int i = 1; ; i += 2){ final int needs = (i / 2 + 1) * (i / 2 + 1); //System.out.println(sum + " " + needs); if(needs > sum){ break; } int over = 0, under = 0; for(int j = 0; j < MAX; j++){ final int need_height = Math.max(0, (i / 2 + 1) - Math.abs((j + 1) - (i / 2 + 1))); //System.out.println(i + " " + j + " " + arr[j] + ":" + need_height + " " + over + " " + under); if(arr[j] < need_height){ under += need_height - arr[j]; }else if(arr[j] > need_height){ over += arr[j] - need_height; } } diff = Math.min(diff, under + over - Math.min(under, over)); } System.out.println(diff); } }