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.*;
import java.util.stream.Collectors;

public class Main {
    InputReader in; PrintWriter out;
    void solve() {

        int n = in.nextInt();
        List<Integer> parents = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            parents.add(in.nextInt());
        }

        List<Pair<Integer, Integer>> edges = new ArrayList<>();
        for (int i = 0; i < parents.size(); i++) {
            edges.add(Pair.of(i + 1, parents.get(i) - 1));
        }
        SimpleUndirectedGraph graph = new SimpleUndirectedGraph(n, edges);
        List<Integer> order = graph.dfsFromSingleVertex(n - 1);
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i < order.size(); i++) {
            result.add(order.get(i) + 1);
            if (order.get(i) == 0) {
                break;
            }
        }
        Collections.reverse(result);
        out.println(result.stream().map(String::valueOf).collect(Collectors.joining(" ")));
    }

    Main(){
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        try {
            if (oj) {
                in = new InputReader(System.in);
                out = new PrintWriter(System.out);
            }
            else {
                Writer w = new FileWriter("output.txt");
                in = new InputReader(new FileReader("input.txt"));
                out = new PrintWriter(w);
            }
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
        solve();
        out.close();
    }
    public static void main(String[] args){
        new Main();
    }
}

class Pair<F, S> {
    private F first;
    private S second;

    private Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    public static <F, S> Pair<F, S> of(F first, S second) {
        return new Pair<>(first, second);
    }

    public F getFirst() {
        return first;
    }

    public S getSecond() {
        return second;
    }
}

class SimpleUndirectedGraph {
    private List<Integer>[] adjacent;

    /* dfs */
    private boolean[] visited = null;
    private List<Integer> dfsResultOrder = null;

    public SimpleUndirectedGraph(int n, Collection<Pair<Integer, Integer>> edges) {
        init(n, edges);
    }

    public void init(int n, Collection<Pair<Integer, Integer>> edges) {
        adjacent = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            adjacent[i] = new ArrayList<>(4 * edges.size() / n);
        }
        for (Pair<Integer, Integer> edge : edges) {
            adjacent[edge.getFirst()].add(edge.getSecond());
            adjacent[edge.getSecond()].add(edge.getFirst());
        }
    }

    public List<Integer> getAdjacentVertices(Integer vertex) {
        return adjacent[vertex];
    }

    public List<Integer> dfsFromSingleVertex(Integer from) {
        if (visited == null) {
            visited = new boolean[adjacent.length];
        }
        if (dfsResultOrder == null) {
            dfsResultOrder = new ArrayList<>(adjacent.length);
        }
        doDfs(from);
        return dfsResultOrder;
    }

    private void doDfs(Integer vertex) {
        dfsResultOrder.add(vertex);
        visited[vertex] = true;
        for (Integer adj : adjacent[vertex]) {
            if (!visited[adj]) {
                doDfs(adj);
            }
        }
    }

}


class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public InputReader(FileReader fr) {
        reader = new BufferedReader(fr);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }

}