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 
    /*
    @author : Abhimanyu Chauhan
    */
    import java.util.*;
    import java.io.*;

    public class TaskA implements Runnable{
        static class Reader
        {
            final private int BUFFER_SIZE = 1 << 16;
            private DataInputStream din;
            private byte[] buffer;
            private int bufferPointer, bytesRead;
    
            public Reader()
            {
                din = new DataInputStream(System.in);
                buffer = new byte[BUFFER_SIZE];
                bufferPointer = bytesRead = 0;
            }
    
            public Reader(String file_name) throws IOException
            {
                din = new DataInputStream(new FileInputStream(file_name));
                buffer = new byte[BUFFER_SIZE];
                bufferPointer = bytesRead = 0;
            }
    
            public String readLine() throws IOException
            {
                byte[] buf = new byte[64]; // line length
                int cnt = 0, c;
                while ((c = read()) != -1)
                {
                    if (c == '\n')
                        break;
                    buf[cnt++] = (byte) c;
                }
                return new String(buf, 0, cnt);
            }
    
            public int nextInt() throws IOException
            {
                int ret = 0;
                byte c = read();
                while (c <= ' ')
                    c = read();
                boolean neg = (c == '-');
                if (neg)
                    c = read();
                do
                {
                    ret = ret * 10 + c - '0';
                }  while ((c = read()) >= '0' && c <= '9');
    
                if (neg)
                    return -ret;
                return ret;
            }
    
            public long nextLong() throws IOException
            {
                long ret = 0;
                byte c = read();
                while (c <= ' ')
                    c = read();
                boolean neg = (c == '-');
                if (neg)
                    c = read();
                do {
                    ret = ret * 10 + c - '0';
                }
                while ((c = read()) >= '0' && c <= '9');
                if (neg)
                    return -ret;
                return ret;
            }
    
            public double nextDouble() throws IOException
            {
                double ret = 0, div = 1;
                byte c = read();
                while (c <= ' ')
                    c = read();
                boolean neg = (c == '-');
                if (neg)
                    c = read();
    
                do {
                    ret = ret * 10 + c - '0';
                }
                while ((c = read()) >= '0' && c <= '9');
    
                if (c == '.')
                {
                    while ((c = read()) >= '0' && c <= '9')
                    {
                        ret += (c - '0') / (div *= 10);
                    }
                }
    
                if (neg)
                    return -ret;
                return ret;
            }
    
            private void fillBuffer() throws IOException
            {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1)
                    buffer[0] = -1;
            }
    
            private byte read() throws IOException
            {
                if (bufferPointer == bytesRead)
                    fillBuffer();
                return buffer[bufferPointer++];
            }
    
            public void close() throws IOException
            {
                if (din == null)
                    return;
                din.close();
            }
        }
        
        Reader scan;
        PrintWriter out;

        @Override
        public void run() {
            try{
                scan = new Reader();
                out = new PrintWriter(System.out);
                solve();
                out.flush();
            }catch(IOException ex){
                ex.printStackTrace();
            }
        }

        int n;
        Stack<Integer> st;
        void dfs(int s){
            vis[s] = true;
            if(s==n-1){
                // out.println(st.toString().trim());
                StringBuilder sb = new StringBuilder("1");
                for(int i : st){
                    sb.append(" ").append(i);
                }
                out.println(sb.toString());
                return;
            }
            for(int i: list[s]){
                if(!vis[i]){
                    st.push(i+1);
                    dfs(i);
                }
            }
            st.pop();
            return;
        }

        List<Integer> list[];
        boolean vis[] ;
        int ar[] ;
        void solve() throws IOException{
            n = scan.nextInt();
            ar = new int[n-1];
            for(int i=0;i<n-1;i++){
                ar[i] = scan.nextInt();
            }
            st = new Stack();
            list = new List[n];
            for(int i=0;i<n;i++){
                list[i] = new ArrayList<>();
            }

            for(int i=0;i<n-1;i++){
                list[i+1].add(ar[i]-1);   
                list[ar[i]-1].add(i+1); 
            }        
            vis = new boolean[n];
            // StringBuilder sb = new StringBuilder("1");
            dfs(0);
            return;
        }

        public static void main(String[] args) throws IOException {
            new Thread(null,new TaskA(),"Main",1<<26).run();;
        }

    }