package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) var rdr = bufio.NewReaderSize(os.Stdin, 1000000) func main() { sc.Split(bufio.ScanWords) n := nextInt() ns, sum := make([]int, 10000), 0 for i := 0; i < n; i++ { c := nextInt() sum += c ns[i] = c } h := 0 for i := 1; ; i++ { if i*i > sum { h = i - 1 break } } count := 0 if ns[h-1] > h { count += ns[h-1] - h } for i := 0; i < h-1; i++ { if ns[i] > i+1 { count += ns[i] - (i + 1) } if ns[i+h] > h-i-1 { count += ns[i+h] - (h - i - 1) } } for i := h*2 - 1; i < len(ns); i++ { count += ns[i] } fmt.Println(count) } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }