#include <bits/stdc++.h>
using namespace std;
const int m = 1e9 + 7;
int deg[200001];
int depth[200001];
vector<vector<int>> v;
void dfs(int u, int p) {
  if (p != -1) depth[u] = depth[p] + 1;
  for (int i = 0; i < v[u].size(); ++i) {
    if (v[u][i] != p) dfs(v[u][i], u);
  }
}
int main() {
  int n;
  cin >> n;
  v.resize(n);
  int root = -1;
  for (int i = 1; i <= n; ++i) {
    int a = i - 1, b;
    cin >> b;
    b--;
    if (b != -1) {
      v[a].push_back(b);
      v[b].push_back(a);
      ++deg[a];
      ++deg[b];
    }
    if (deg[a] > 1) root = a;
    if (deg[b] > 1) root = b;
  }
  root = max(root, 0);
  dfs(root, -1);
  set<pair<int, int>> st;
  for (int i = 0; i < n; ++i) {
    if (deg[i] % 2 == 0) st.insert({-depth[i], i});
  }
  vector<int> sol;
  while (st.size()) {
    pair<int, int> top = *st.begin();
    st.erase(top);
    if (deg[top.second] > 0)
      for (int i = 0; i < v[top.second].size(); ++i) {
        int next = v[top.second][i];
        if (deg[next] == 0) continue;
        deg[next]--;
        if (deg[next] % 2 == 0)
          st.insert({-depth[next], next});
        else
          st.erase({-depth[next], next});
      }
    deg[top.second] = 0;
    sol.push_back(top.second + 1);
  }
  if (sol.size() == n) {
    cout << "YES" << endl;
    for (int x : sol) cout << x << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
