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;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<double, double>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
const long double PI = 3.14159265358979323;
const long long MOD = 1e9 + 7;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
  size_t operator()(pair<uint64_t, uint64_t> x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM) ^
           (splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct coord {
  int x;
  int y;
  int poz;
};
bool asc(coord l, coord r) {
  return (l.x != r.x) ? l.x < r.x : ((l.y != r.y) ? l.y < r.y : l.poz < r.poz);
}
bool desc(coord l, coord r) {
  return (l.x != r.x) ? l.x > r.x : ((l.y != r.y) ? l.y > r.y : l.poz > r.poz);
}
struct Node {
  int nr;
  vector<Node*> edges;
  bool visited = false;
  bool active = false;
  int distance;
};
list<Node*> activeNodes;
list<Node*> result;
int n, m, k, t, a, b, rez, mas[100005];
void dfs(Node* node) {
  if (node->visited) {
    return;
  }
  activeNodes.push_back(node);
  if (node->nr == n - 1) {
    result = activeNodes;
  }
  node->visited = true;
  node->active = true;
  for (Node* newNode : node->edges) {
    if (!newNode->active) {
      newNode->distance = max(newNode->distance, node->distance + 1);
    }
    if (!newNode->visited) {
      dfs(newNode);
    }
  }
  activeNodes.pop_back();
  node->active = false;
}
void bfs(Node* node) {
  if (node->visited) {
    return;
  }
  queue<Node*> q;
  for (q.push(node); !q.empty(); q.pop()) {
    node = q.front();
    for (Node* newNode : node->edges) {
      if (!newNode->visited) {
        newNode->visited = true;
        newNode->distance = max(newNode->distance, node->distance + 1);
        q.push(newNode);
      }
    }
  }
}
Node nodes[200005];
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  nodes[0].nr = 0;
  for (int i = (1); i < (n); i++) {
    cin >> a;
    nodes[i].nr = i;
    nodes[a - 1].edges.push_back(&nodes[i]);
  }
  dfs(&nodes[0]);
  for (Node* node : result) {
    cout << node->nr + 1 << " ";
  }
  return 0;
}
