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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;


public class main {


    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    static long gcd(long a, long b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static long findGCD(int arr[])
    {
        long result = arr[1];
        for (int i = 1; i <arr.length-1 ; i++)
            result = gcd(arr[i], result);

        return result;
    }
    private static long[] getLongArrar(int size) {
        long arr[] = new long[size + 2];
        for (int i = 0; i <= size; i++) {
            arr[i] = in.nextLong();
        }
        return arr;
    }
    private static String[] getStringArray(int size) {
        String arr[] = new String[size + 2];
        for (int i = 1; i <= size; i++) {
            arr[i] = in.next();
        }
        return arr;
    }
    private static int[] getIntArray(int size) {
        int arr[] = new int[size + 2];
        for (int i = 1; i <= size; i++) {
            arr[i] = in.nextInt();
        }
        return arr;
    }
    private static long[] CumulativeOfArrayCreator(int arr[],int size){
        long cumulative [] =new long[size];
        cumulative[0]=arr[0];
        for(int i=1;i<size;i++){
            cumulative[i]=cumulative[i-1]+arr[i];
        }
        return cumulative;
    }
    private static int ModifiedBinarySearch(int a[],int start,int end,long value){
        // this search INDEX will find greatest element small or equal to the value

        int mid=-1;
        int nearest=start;
        while(start<=end){
            mid=(start+end)/2;
            if(a[mid]<value) {
                nearest=mid;
                start=mid+1;
            }else if (a[mid]>value){
                end=mid-1;
            }else{
                return mid;
            }
        }
        return nearest;
    }














    static FastReader in;
    static StringBuilder out;

    private static long[] manage(long a[]){
        long sum = 0;
        for(int i=0;i<a.length;i++){
            sum+=a[i];
        }
        int start=0,end=a.length-1;
        long b[] = new long[a.length];
        int index =a.length-1;
        b[index]  = sum;
        while (start<end){
            --index;
            if(a[start]>a[end]){
                sum-=a[start];
                start++;
            }else {
                sum-=a[end];
                end--;
            }
            b[index] = sum;
        }
        b[0]= a[end];
        return b;
    }

    public static void main(String[] args) {
        out=new StringBuilder();
        in = new FastReader();

        int n = in.nextInt();
        int a[] = new int[n+1];
        for(int i=2;i<1+n;i++){
            a[i]=in.nextInt();
        }
        a[1]= 1;
        int i=2;

        while (i<n+1){
            if(a[a[i]]!=0){

            }else{
                a[i]=0;
            }
            i++;
        }
        int b[]= new int[n+1];

        i=n;
        int j=n;
        while (i!=1){
            b[j]=i;
            j--;
            i=a[i];
        }
        System.out.print(1+ " ");
        for(int k = j+1;k<=n;k++)
            System.out.print(b[k]+" ");
    }
}

/*
in = new FastReader();

        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=in.nextInt();
        }

        Arrays.sort(a);
        int mid = n/2;
        if(a[mid]==s){
            System.out.println(0);
            return;
        }
        long sum=0;
        int Lindex = ModifiedBinarySearch(a,0,a.length-1,s);
        if(Lindex<mid){
            for(int i=Lindex+1;i<=mid;i++){
                sum+=Math.abs(a[i]-s);
            }
        }else{
            for (int i=mid;i<=Lindex;i++){
                sum+=Math.abs(a[i]-s);
            }
        }
        System.out.println(sum);
*/