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 
//package power.rankings;

import java.util.*;
import java.io.*;

public class PowerRankings {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        int n = readInt(), pre[] = new int[n+1]; pre[1] = -1;
        for(int i = 2; i <= n; i++){pre[i] = readInt();}
        Stack<Integer> stack = new Stack();
        for(int cur = n; cur != -1; cur = pre[cur]){
            stack.push(cur);
        }while(!stack.isEmpty())System.out.println(stack.pop());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine().trim());
        }
        return st.nextToken();
    }

    static long readLong() throws IOException {
        return Long.parseLong(next());
    }

    static int readInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double readDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static char readCharacter() throws IOException {
        return next().charAt(0);
    }

    static String readLine() throws IOException {
        return br.readLine().trim();
    }

    static int upper_bound(long a[], long key) {
        int lo = 0, hi = a.length - 1;
        while (lo <= hi) {
            int mid = (lo + hi) / 2;
            if (a[mid] == key) {
                lo = mid + 1;
            } else if (a[mid] > key) {
                hi = mid - 1;
            } else {
                lo = mid + 1;
            }
        }
        return hi;
    }

    static int lower_bound(int a[], int key) {
        int lo = 0, hi = a.length - 1;
        while (lo <= hi) {
            int mid = (lo + hi) / 2;
            if (a[mid] == key) {
                hi = mid - 1;
            } else if (a[mid] > key) {
                hi = mid - 1;
            } else {
                lo = mid + 1;
            }
        }
        return lo;
    }

    static int gcd(int x, int y) {
        return y == 0 ? x : gcd(y, x % y);
    }

    public static int modexponent(int x, int exp, int mod) {
        if (exp == 0) {
            return 1;
        }
        int t = modexponent(x, exp / 2, mod);
        t = (t * t) % mod;
        if (exp % 2 == 0) {
            return t;
        }
        return (t * x % mod) % mod;
    }

    public static boolean next_permutation(char a[]) {
        int n = a.length;
        int p = n - 2;
        int q = n - 1;

        while (p >= 0 && a[p] >= a[p + 1]) {
            p--;
        }
        if (p < 0) {
            return false;
        }

        while (a[q] <= a[p]) {
            q--;
        }
        char t = a[p];
        a[p] = a[q];
        a[q] = t;

        for (int i = p + 1, j = n - 1; i < j; i++, j--) {
            t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
        return true;
    }

    static long getSubHash(long hash[], long pow[], int l, int r) {
        return hash[r] - hash[l - 1] * pow[r - l + 1];
    }

}
