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 
// Java program to print DFS traversal from a given given graph 
import java.io.*; 
import java.util.*; 

// This class represents a directed graph using adjacency list 
// representation 
public class NewClass 
{ 
	private int V; // No. of vertices 
        static int n;
        static int count=0;
        static int a[];
	// Array of lists for Adjacency List Representation 
	private LinkedList<Integer> adj[]; 

	// Constructor 
	NewClass(int v) 
	{ 
		V = v+1; 
		adj = new LinkedList[v+1]; 
		for (int i=0; i<v+1; ++i) 
			adj[i] = new LinkedList(); 
	} 

	//Function to add an edge into the graph 
	void addEdge(int v, int w) 
	{ 
		adj[v].add(w); // Add w to v's list. 
	} 

	// A function used by DFS 
	boolean DFSUtil(int v,boolean visited[]) 
	{ 
		// Mark the current node as visited and print it 
		visited[v] = true; 
		//System.out.print(v+" "); 

		// Recur for all the vertices adjacent to this vertex 
		Iterator<Integer> i = adj[v].listIterator(); 
		while (i.hasNext()) 
		{ 
			int N = i.next(); 
                        if(N == n){
                            //System.out.println(n + "==");
                            a[count++]=n;
                            a[count++]=v;
                            //count++;
                            return true;
                        }
			if (!visited[N]){ 
                            if(DFSUtil(N, visited)){
                                a[count++]=v;
                                return true;
                            } 
		
                        }
                }
                return false;
	} 

	// The function to do DFS traversal. It uses recursive DFSUtil() 
	void DFS(int v) 
	{ 
		// Mark all the vertices as not visited(set as 
		// false by default in java) 
		boolean visited[] = new boolean[V]; 

		// Call the recursive helper function to print DFS traversal 
		DFSUtil(v, visited); 
	} 

	public static void main(String args[]) 
	{ 
		Scanner sc = new Scanner(System.in);
                n =sc.nextInt();
		NewClass g = new NewClass(n); 
                int arr[] = new int [n+1];
                a =new int[n];
        
                for(int i=2;i<arr.length;i++){
                    arr[i] = sc.nextInt();
                }
                for(int i=2;i<n+1;i++){
                    /*array[arr[i]][i] = 1;
                    array[i][arr[i]] = 1;*/
                    g.addEdge(arr[i], i);
                    g.addEdge(i, arr[i]);
                }
		/*g.addEdge(0, 1); 
		g.addEdge(0, 2); 
		g.addEdge(1, 2); 
		g.addEdge(2, 0); 
		g.addEdge(2, 3); 
		g.addEdge(3, 3); 
                */
		//System.out.println("Following is Depth First Traversal "+ 
						//"(starting from vertex 2)"); 

		g.DFS(1);
                for(int i=count-1;i>=0;i--){
                    System.out.print(a[i]+" ");
                }
	} 
} 
// This code is contributed by Aakash Hasija 
