Once upon a time there was only one router in the well-known company Bmail. Years went by and over time new routers were purchased. Every time they bought a new router, they connected it to one of the routers bought before it. You are given the values p_i — the index of the router to which the i-th router was connected after being purchased (p_i < i).

There are n routers in Boogle in total now. Print the sequence of routers on the path from the first to the n-th router.

Input

The first line contains integer number n (2 ≤ n ≤ 200000) — the number of the routers. The following line contains n-1 integers p_2, p_3, ..., p_n (1 ≤ p_i < i), where p_i is equal to index of the router to which the i-th was connected after purchase.

Output

Print the path from the 1-st to the n-th router. It starts with 1 and ends with n. All the elements in the path should be distinct.

Examples

Input

8
1 1 2 2 3 2 5


Output

1 2 5 8 

Input

6
1 2 3 4 5


Output

1 2 3 4 5 6 

Input

7
1 1 2 3 4 3


Output

1 3 7 
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001;
int powi(int x, int n) {
  int res = 1;
  while (n) {
    if (n & 1) res = (res * x) % MOD;
    x = (x * x) % MOD;
    n >>= 1;
  }
  return res;
}
bool isPowerOfTwo(int n) {
  if (n == 0) return 0;
  while (n != 1) {
    if (n % 2 != 0) return 0;
    n = n / 2;
  }
  return 1;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
int dfs(int** edges, bool* visited, int si, int n) {
  visited[si] = true;
  int p = 1;
  for (int i = 1; i < (n + 1); i++) {
    if (edges[si][i] == 1) {
      if (visited[i]) continue;
      int y = dfs(edges, visited, i, n);
      if (y + 1 > p) p = y + 1;
    }
  }
  return p;
}
bool visited[200005];
bool validpoint(int i, int j, int r, int c) {
  if ((i >= 0 && i < r) && (j >= 0 && j < c))
    return true;
  else
    return false;
}
bool check(vector<string>& v, int r, int c, int i, int j) {
  int tp[4][2] = {{i + 1, j}, {i, j + 1}, {i - 1, j}, {i, j - 1}};
  for (int i = 0; i < (4); i++) {
    int ni = tp[i][0];
    int nj = tp[i][1];
    if (validpoint(ni, nj, r, c) && v[ni][nj] == 'S') return true;
  }
  return false;
}
const int N = 1e5;
bool ck(vector<vector<int>>& edges, int n, vector<int>& ans, int si) {
  if (si == n) {
    return true;
  }
  visited[si] = true;
  while (!edges[si].empty()) {
    int r = edges[si].back();
    edges[si].pop_back();
    if (visited[r]) continue;
    ans.push_back(r);
    if (r == n) {
      return true;
    } else if (ck(edges, n, ans, r)) {
      return true;
    } else
      ans.pop_back();
  }
  return false;
}
void solve() {
  int n;
  cin >> n;
  vector<vector<int>> edges(n + 1);
  for (int i = 2; i < (n + 1); i++) {
    int second;
    cin >> second;
    edges[i].push_back(second);
    edges[second].push_back(i);
  }
  for (int i = 0; i < (200005); i++) {
    visited[i] = false;
  }
  visited[1] = true;
  while (!edges[1].empty()) {
    int q = edges[1].back();
    visited[q] = true;
    edges[1].pop_back();
    {
      vector<int> ans;
      ans.push_back(q);
      if (ck(edges, n, ans, q)) {
        cout << 1 << " ";
        for (auto& x : ans) cout << x << " ";
      } else
        ans.pop_back();
    }
  }
}
int z = 0;
bool check(int mid, int index) {
  int x;
  int y;
  cout << "?"
       << " " << index + 1 << "\n";
  cout.flush();
  cin >> x;
  cout << "?"
       << " " << index - 1 << "\n";
  cout.flush();
  cin >> y;
  if (x > mid && y > mid)
    return true;
  else {
    if (y > x)
      z = -1;
    else if (x > y)
      z = 1;
    return false;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
