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 
import java.util.*;
import java.io.*;
public class UVa {
  static class FastIO {
        InputStream dis;
        byte[] buffer = new byte[1 << 17];
        int pointer = 0;
        public FastIO(String fileName) throws Exception {
          dis = new FileInputStream(fileName);
        }
        public FastIO(InputStream is) throws Exception {
          dis = is;
        }
        public int nextInt() throws Exception {
          int ret = 0;
          byte b;
          do {
              b = nextByte();
          } while (b <= ' ');
          boolean negative = false;
          if (b == '-') {
              negative = true;
              b = nextByte();
          }
          while (b >= '0' && b <= '9') {
              ret = 10 * ret + b - '0';
              b = nextByte();
          }
          return (negative) ? -ret : ret;
        }
        public long nextLong() throws Exception {
          long ret = 0;
          byte b;
          do {
              b = nextByte();
          } while (b <= ' ');
          boolean negative = false;
          if (b == '-') {
              negative = true;
              b = nextByte();
          }
          while (b >= '0' && b <= '9') {
              ret = 10 * ret + b - '0';
              b = nextByte();
          }
          return (negative) ? -ret : ret;
        }
        public byte nextByte() throws Exception {
          if (pointer == buffer.length) {
              dis.read(buffer, 0, buffer.length);
              pointer = 0;
          }
          return buffer[pointer++];
        }
        public String next() throws Exception {
          StringBuffer ret = new StringBuffer();
          byte b;
          do {
              b = nextByte();
          } while (b <= ' ');
          while (b > ' ') {
              ret.appendCodePoint(b);
              b = nextByte();
          }
          return ret.toString();
        }
  }  
    
  static ArrayList<Integer> path = new ArrayList<Integer>();
  static int n;
  static ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
  static boolean[] visited;
  public static void main(String[] args) throws Exception{
    FastIO r = new FastIO(System.in);
    n = r.nextInt();
    visited = new boolean[n];
    for(int i = 0; i < n; i++){
      adj.add(new ArrayList<Integer>());
    }
    for(int i = 1; i < n; i++){
      int val = r.nextInt() - 1;
      adj.get(val).add(i);
    }
    dfs(0);
    for(int i : path){
      System.out.print(i + " ");
    }
    System.out.println();
  }
  static boolean hasFound = false;
  public static void dfs(int cur){
    visited[cur] = true;
    path.add(cur + 1);
    if(cur == n - 1) hasFound = true;
    if(hasFound) return;
    int num = 0;
    for(int i : adj.get(cur)){
      if(!visited[i] && !hasFound){
        dfs(i);
        num++;
      }
    }
    if(num == 0) {
      path.remove(path.size() - 1);
    }
    else if(!hasFound) path.remove(path.size() - 1);
  }
}