func main() var n: int :: cui@inputInt() var ans: int :: 0 var idx: int :: 0 for i(0, n - 1) var b: int :: cui@inputInt() for(1, b) do ans :+ (idx - i).abs() do idx :+ 1 end for end for do cui@print("\{ans}\n") end func