Gift Giving

 

Input file:          gift.in                                                                     100 points

Output file:       gift.out                                                           Time limit: 1sec

Source Code:    gift.pas/.c/.cpp                                   Memory limit: 16 MB

 

You and your classmates have decided to give gifts to each other. Each student has expressed her/his wish, by naming exactly one other student, whom she/he wants to present a gift. You realized, however, the chance that some students may get no gift at all, while others would receive more than one.

Task

You are to write a program that computes the “gift giving and getting” party of students, i.e. the largest subset of selected students who will get exactly one gift from another selected student.

Input

The first line of the text file gift.in contains a single integer, N (2 ≤ N ≤ 1 000 000), the number of students. Students are identified by the numbers from 1 to N. The second line contains exactly N integers, specifying the wishes. The ith number, Si, is the identifier of the student, whom the ith student wants to present a gift (Sii).

Output

The first line of the text file gift.out contains a single integer, M, the number of the elements of the largest subset of selected students, i.e. students who belong to the “gift giving and getting” party. The second line contains M integers in increasing order, the identifiers of the students who belong to that party.

Example

gift.in

gift.out

13
2 4 2 5 6 7 4 7 10 12 10 13 12

6
4 5 6 7 12 13