import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int A[] = new int[101]; Arrays.fill(A, 0); // 1オリジン for(int i = 1; i <= N; i++) { A[i] = scan.nextInt(); } scan.close(); int sum = 0; for(int i = 1; i <= N; i++) { sum += A[i]; } int n = 1; int cost = 0; for(int i = 1; i < 100; i++) { if(sum == i * i) { n = i; break; }else if(sum < i * i) { n = i - 1; break; } } //cost = sum - n * n; cost = 0; for(int i = 1; i <= 2 * n - 1; i++) { if(i <= n) { if(A[i] >= i) { cost += i; }else { cost += A[i]; } }else { int t = 2 * n - i; if(A[i] >= t) { cost += t; }else { cost += A[i]; } } } int ans = sum - cost; System.out.println(ans); } }