import sequtils, strutils let nm, xs = stdin.readLine.split.map parseInt n = nm[0] var seq1 = (1 .. n).toSeq for a in xs: let x = seq1[a.pred] seq1.delete a.pred seq1.insert x echo seq1[0]