#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
vector<int> G[maxn];
bool visited[maxn];
bool dfs(int u, int fa) {
  bool bet = false;
  for (unsigned int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    visited[v] = dfs(v, u);
    if (!visited[v]) bet = !bet;
  }
  return bet;
}
void print(int u, int fa) {
  for (unsigned int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    if (visited[v]) print(v, u);
  }
  cout << u << endl;
  for (unsigned int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    if (!visited[v]) print(v, u);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, rt, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == 0)
      rt = i;
    else {
      G[x].push_back(i);
      G[i].push_back(x);
    }
  }
  memset(visited, false, sizeof(visited));
  if (!dfs(rt, 0)) {
    cout << "YES" << endl;
    print(rt, 0);
  } else
    cout << "NO" << endl;
  return 0;
}
