import strutils, sequtils, tables proc main() = let n = stdin.readLine.strip.parseInt a = stdin.readLine.strip.split.map(parseInt) var right = initTable[int, int]() for i in 0.. 0 and right[stack[^1]] <= i: discard stack.pop echo b main()