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;
long long powmod(long long base, long long exp, long long MOD = 1000000007) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % MOD;
    base = (base * base) % MOD;
    exp /= 2;
  }
  return (res % MOD);
}
long long mul_inv(long long a, long long b = 1000000007) {
  long long t1 = a, t2 = b, t3, v1 = 1, v2 = 0, v3;
  while (t2 != 1) {
    long long x = t1 / t2;
    t3 = t1 - x * t2;
    v3 = v1 - x * v2;
    t1 = t2, t2 = t3;
    v1 = v2, v2 = v3;
  }
  return (v2 + b) % b;
}
pair<bool, vector<long long> > dfs(vector<vector<long long> > &adj,
                                   long long i) {
  vector<long long> tp;
  tp.push_back(i + 1);
  if (i == adj.size() - 1) {
    return make_pair(true, tp);
  }
  for (long long j = 0; j < adj[i].size(); j++) {
    pair<bool, vector<long long> > temp = dfs(adj, adj[i][j]);
    if (temp.first == true) {
      temp.second.push_back(i + 1);
      return temp;
    }
  }
  return make_pair(false, tp);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<vector<long long> > adj(n, vector<long long>());
  for (long long i = 0; i < n - 1; i++) {
    long long k;
    cin >> k;
    adj[k - 1].push_back(i + 1);
  }
  pair<bool, vector<long long> > ans = dfs(adj, 0);
  reverse(ans.second.begin(), ans.second.end());
  for (auto t : ans.second) cout << t << " ";
  cout << endl;
}
