import strutils, sequtils let N, A = stdin.readLine.split.map parseInt var arr = newSeqWith(N[0], 0) for i, v in arr: arr[i] = i + 1 for i in 0 ..< A.len: let k = A[i] - 1 let v = arr[k] delete(arr, k) insert(arr, v) echo arr[0]