local n = io.read("*n") local t = {} local ans = {} local ngcnt = {} local idx = {} for i = 1, n do ans[i] = 1000000007 idx[i] = i ngcnt[i] = 0 t[i] = {} for j = 1, n do t[i][j] = true end end for i = 1, n do local a = io.read("*n") + 1 if a <= n then t[i][a] = false ngcnt[a] = ngcnt[a] + 1 end end table.sort(idx, function(a, b) return ngcnt[a] < ngcnt[b] end) if ngcnt[idx[n]] == n then print(-1) os.exit() end local function debug() print("---") for i = 1, n do for j = 1, n do io.write(t[i][j] and 1 or 0) io.write(j == n and "\n" or " ") end end end for i = 1, n do -- debug() local num = idx[#idx] for iuser = 1, n do if t[iuser][num] then ans[iuser] = num - 1 for j = 1, n do if t[iuser][j] then ngcnt[j] = ngcnt[j] + 1 end t[j][num] = false t[iuser][j] = false end break end end if i ~= n then table.remove(idx) table.sort(idx, function(a, b) return ngcnt[a] < ngcnt[b] end) end end print(table.concat(ans, "\n"))