local n = io.read("*n") local t = {} for i = 1, n - 1 do t[i] = {} end for i = 1, n - 1 do local a = io.read("*n") table.insert(t[a], i) end for i = 1, n - 1 do for j = 1, #t[i] do local k = #t[i] + 1 - j if j < k then t[i][j], t[i][k] = t[i][k], t[i][j] else break end end end local ret = {} for i = 1, n - 1 do ret[i] = 0 end local curlen = 1 for dst = 2, n do while curlen < n and #t[curlen] == 0 do curlen = curlen + 1 end if (dst - 1) < curlen then print("NO") os.exit() end local q = t[curlen][#t[curlen]] table.remove(t[curlen]) ret[q] = dst - curlen end print("YES") print(table.concat(ret, "\n"))