Ancestors#437

Ancestors

1 second
128 megabytes
Very easy

Examining the genes of several thousand people, scientists have hypothesized that all of humanity originated from a small tribe of people who lived somewhere in West Africa.

The Association of Cloned Martians decided to conduct a similar study for the inhabitants of Mars. Write a program for ACM that, using the results of a large genetic study of Martians, determines for each Martian their ancestor (progenitor).

Input

The first line contains the number (1 < n \le 10^5) — the number of surveyed Martians. The following lines each contain a single integer from to . In the (i+1)-st line, the number denotes the parent of the -th Martian, or if the Martian has no parent (i.e., is a progenitor, like Adam or Eve in the Bible). The input data does not contain cycles.

Output

For each Martian, print the number of their progenitor, or if the Martian is a progenitor.

Examples

Example 1

Loading
Loading