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.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class BMailComputerNetwork {

	public static class ans{
		ArrayList<Integer> order;
		boolean possible;
		
		public ans(boolean possible) {
			this.possible=possible;
			order=new ArrayList<>();
		}
	}
	
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader ();
		int n=s.nextInt();
		LinkedList<Integer>[] adjlinkedlist=new LinkedList[n];
		for(int i=0;i<n;i++) {
			adjlinkedlist[i]=new LinkedList<Integer>();
		}
		int[] arr=new int[n];
		for(int i=0;i<n-1;i++) {
			arr[i]=s.nextInt();
			adjlinkedlist[arr[i]-1].add(i+1);
		}
		ans ans=recursion(n,0,adjlinkedlist);
		Collections.sort(ans.order);
		for(Integer x:ans.order) {
			out.print((x+1)+" ");
		}
		out.close();
	}

	public static ans recursion(int n,int src,LinkedList<Integer>[] adjlinkedlist) {
		if(src==n-1) {
			ans temp=new ans(true);
			temp.order.add(src);
			return temp;
		}
		ans ans=new ans(false);
		for(Integer x:adjlinkedlist[src]) {
			ans temp=recursion( n,x,adjlinkedlist);
			if(temp.possible) {
				ans=temp;
				break;
			}
		}
		if(ans.possible)ans.order.add(src);
		return ans;
	}
	
	public static PrintWriter out;
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
}
