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.*;
import java.util.*;
public class working
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        
        int n=sc.nextInt();
        int[] par=new int[n+1];
        par[1]=0;
        for(int tt=2;tt<=n;tt++){
            int x=sc.nextInt();
            par[tt]=x;
        }
        List<Integer> res=new ArrayList<>();
        int temp=n;
        while(temp!=0){
            res.add(temp);
            temp=par[temp];
        }
        for(int i=res.size()-1;i>=0;i--) out.print(res.get(i)+" ");
        out.println();
    	out.close();
 
    }
    
    // private static int dfs(ArrayList<Integer>[] adj,int i){
    //     if(adj[i].size()==0) return 1;
    //     int res=0;
    //     for(int j:adj[i]){
    //         res=Math.max(res,dfs(adj,j));
    //     }
    //     return res+1;
    // }
    
    // private static void dfs(ArrayList<Integer>[] adj,int i,int par,boolean[] vis){
    //     for(int j:adj[i]){
    //         if(j!=par){
    //             vis[j]=true;
    //             dfs(adj,j,i,vis);
    //         }
    //     }
    // }

    // private static boolean possible(char[][] grid,int i,int j){
    //     return (i>=0 && j>=0 && i<grid.length && j<grid[0].length);
    // }
    /*
    int n=sc.nextInt();
        	char[] s=sc.next().toCharArray();
        	int res=0;
        	for(int i=1;i<n;i++){
        		if( (s[i]=='1') && s[i]==s[i-1]) res++;
        	}
        	out.println(res);
    
    private static int modInverse(int a, int m) 
    { 
        a = a % m; 
        for (int x = 1; x < m; x++) 
           if ((a * x) % m == 1) 
              return x; 
        return 1;  
   }
    
    private static int gcd(int a,int b){
    	if(b==0) return a;
    	return gcd(b,a%b);
    }
    
    private static int dfs(ArrayList<Integer>[] adj,int[] arr,int i,int par){
    	if(adj[i].size()==0) return arr[i];
    	int curr=arr[i],s=adj[i].size();
    	int max=0;
        for(int j:adj[i]){
        	if(j==par) continue;
        	int temp=dfs(adj,arr,j,i);
        	max=Math.max(max,temp);
        	curr+=temp;
        }
        int rem=curr%s;
        if(rem>0) rem=1;
        int ans=rem+curr/s;
        if(max>ans) return max;
        return ans;
    }
     */
    public static long pow(long a,long b){
        if(b==0){
            return 1;
        }
        if(b%2==0){
            return pow(a*a,b/2);
        }else{
            return a*pow(a*a,b/2);
        }
    }
    static class Reader 
    { 
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        public int nextInt()
        {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    } 
}
 