Tree Country Tour Guide

Given the move sequence of a shortest round trip that visits every node of an unknown rooted tree, reconstruct each city's parent.

Medium6StackTreeDFSNo attempts yetTime limit1sMemory limit512 MB

Problem

Yunho is a tour guide in Tree Country, where KK cities are connected in the shape of a tree. His new package tour starts at the root city of Tree Country, visits every city, and returns to the root. Only the concept of the package is fixed, so Yunho decides the order in which to visit the cities. Eager to finish work quickly, Yunho has been running tours in an order that uses the fewest possible moves among all orders that visit every city and return.

For example, in a Tree Country whose root city is city 00, one visiting order chosen by Yunho is as follows.

0-1-2-1-3-4-3-5-3-1-6-1-0-7-8-7-9-7-0

One day, Yunho lost his map. Fortunately, his tour plan still records the order in which the cities must be visited. He decided to redraw the map from it, but the task was too difficult for him, so you, even more frustrated, decided to report the parent city of every city on his behalf.

For the order above, the corresponding map is expressed by saying that city 00 has no parent, the parent of city 11 is city 00, the parent of city 22 is city 11, and so on.

Input

Input is given from standard input. The first line contains the length NN (1N200,0001 \le N \le 200{,}000) of Yunho's visiting order.

The second line contains NN integers. The ii-th integer AiA_i is the number of the ii-th visited city, and it is guaranteed that there exists a tree that can be visited in the given order. If there are KK cities, the cities are numbered from 00 to K1K-1 with no duplicates. That is, 0Ai<K0 \le A_i < K.

Output

Print to standard output. On the first line, print the total number KK of cities in Tree Country.

On the second line, print KK integers separated by spaces. The ii-th number is the parent city of city ii, or 1-1 for the root city, which has no parent.