func main() var n: int :: cui@inputInt() var a: []int :: #[n]int for i(0, n - 1) do a[i] :: cui@inputInt() end for var ans: int :: n for i(n - 1, 0, -1) if(a[i] = ans) do ans :- 1 end if end for do cui@print("\{ans}\n") end func