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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class a{ 
     static int[] count,count1,count2;
     static int[] arr;
     static char[] ch,ch1;
     static int[] darr,farr;
     static Character[][] mat,mat1;
     static long x,h;
     static long maxl;
     static double dec;
     static String s;
     static long minl;
     static int mx = (int)1e6;
     static long mod = 998244353l;
     // static int minl = -1;
     // static long n;
     static int n,n1,n2;
     static long a,l,g;
     static long b;
     static long c;
     static long d;
     static long y,z;
     static int m;
     static long k;
     static int q;
     static String[] str,str1;
     static Set<Integer> set,set1;
     static List<Integer> list,list1,list2;
     static LinkedList<Character> ll;
     static Map<Integer,Integer> map;
     static StringBuilder sb,sb1,sb2;

     public static void solve(){

        arr[1] = 1;
        int i = n;

        sb = new StringBuilder();
        int[] vis = new int[n+1];
        vis[n] = 1;

        while(i != arr[i]){
            vis[arr[i]] = 1;
            i = arr[i];
        }

        for(i = 1 ;  i <= n ; i++)
            if(vis[i] == 1)
                sb.append(i+" ");

        System.out.println(sb);

     }

     public static void main(String[] args) {

            FastScanner sc = new FastScanner();
            // Scanner sc = new Scanner(System.in);
            // int t = sc.nextInt();
            int t = 1;
            while(t > 0){
                
                // x = sc.nextLong();
                // y = sc.nextLong();
                // z = sc.nextLong();
                
                // a = sc.nextLong();
                // b = sc.nextLong();
                // c = sc.nextLong();
                // d = sc.nextLong();
                // n = sc.nextLong();
                n = sc.nextInt();
                // m = sc.nextInt();
                // x = sc.nextLong();
                // y = sc.nextLong();
                // x = sc.newxtLong();

                // y = sc.nextLong();
                // n1 = sc.nextInt();
                // n = sc.nextLong();

                // k = sc.nextLong();

                // ch = sc.next().toCharArray();
                // ch1 = sc.next().toCharArray();

                // m = sc.nextLong();
                // k = sc.nextLong();

                arr = new int[n+1];
                for(int i = 2; i <= n ; i++){
                    arr[i] = sc.nextInt();
                }
                 
                // darr = new int[n];
                // for(int i = 0; i < n ; i++){
                //     darr[i] = sc.nextInt();
                // }
                
                // n1 = sc.nextInt();
                //  darr = new long[n1];
                //  for(int i = 0; i < n1 ; i++){
                //      darr[i] = sc.nextLong();
                //  }

                // mat = new Character[n][n];
                // for(int i = 0 ; i < n ; i++){
                //     String s = sc.next();
                //     for(int j = 0 ; j < n ; j++){
                //         mat[i][j] = s.charAt(j);
                //     }
                // }
                // str = new String[n];
                // for(int i = 0 ; i < n ; i++)
                //     str[i] = sc.next();

                // System.out.println(solve()?"Yes":"No");
                 solve();       
                 // System.out.println(solve());

                 t -= 1;
            }

     }

    public static int log(long n){

         if(n == 0 || n == 1)
             return 0;

         if(n == 2)
             return 1;

         double num = Math.log(n);
         double den = Math.log(2);

         if(den == 0)
             return 0;

         return (int)(num/den);
     }

     public static long gcd(long a,long b){

        if(b%a == 0)
            return a;

        return gcd(b%a,a);

     }

     // public static void swap(int i,int j){
     //     long temp = arr[j];
     //     arr[j] = arr[i];
     //     arr[i] = temp;
     // } 

    static final Random random=new Random();
    
    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort 
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class Node{
        int first;
        int second;
        Node(int f,int s){
            this.first = f;
            this.second = s;
        }
    }

     static class FastScanner {

                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }
                
                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] readArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
        }

}