func main() var n: int :: cui@inputInt() var a: []int :: #[2 * n]int for i(0, n - 1) do a[i] :: cui@inputInt() end for var ans: int :: 10000 for c(0, 2 * n - 1) var r: int :: 2 * c if(r > 2 * n - 1) break c end if do ans :: [ans, f(a, c, r)].min() end for do cui@print("\{ans}\n") func f(a: []int, center: int, right: int): int var plus: int var minus: int for i(0, ^a - 1) if(i <= center) var targetVal: int :: i + 1 if(a[i] > targetVal) do plus :+ a[i] - targetVal elif(a[i] < targetVal) do minus :+ targetVal - a[i] end if elif(center < i & i <= right) var targetVal: int :: right - i + 1 if(a[i] > targetVal) do plus :+ a[i] - targetVal elif(a[i] < targetVal) do minus :+ targetVal - a[i] end if else do plus :+ a[i] end if end for if(plus >= minus) ret plus else ret 10000 end if end func end func