text: out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskB solver = new TaskB(); solver.solve(1, in, out); out.close(); } static class TaskB { static final int N = (int) 2e5 + 1; int n; List<Integer>[] graph = new ArrayList[N]; int[] sz = new int[N]; int root; OutputWriter out; public void solve(int testNumber, InputReader in, OutputWriter out) { this.out = out; n = in.readInt(); for (int i = 1; i <= n; i++) graph[i] = new ArrayList<>(); for (int i = 1; i <= n; i++) { int p = in.readInt(); if (p == 0) root = i; else graph[p].add(i); } if (n % 2 == 0) { out.printLine("NO"); return; } out.printLine("YES"); countEdges(root); removeVertices(root); } void countEdges(int cur) { sz[cur] = 1; for (int nxt : graph[cur]) { countEdges(nxt); sz[cur] += sz[nxt]; } } void removeVertices(int cur) { for (int nxt : graph[cur]) { if (sz[nxt] % 2 == 0) { removeVertices(nxt); } } out.printLine(cur); for (int nxt : graph[cur]) { if (sz[nxt] % 2 != 0) { removeVertices(nxt); } } } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.