Value Equal to Index Value

Practice this coding question on Coding Gurukul.

Problem statement

A library places numbered labels on a row of shelves. The auditor wants the positions where a shelf's stored label agrees with its position in the row. Your task Find every one-based index i for which the array value a[i] equals i. Important details Positions start at one, not zero. Output all matching positions in increasing order; because a matching value equals its position, these are also the matching values. Repeated labels are permitted, but only their own matching positions qualify. If there are no matches, print the specified NONE marker. A single left-to-right scan is sufficient and keeps the output naturally ordered. Worked example For labels 1 8 3 4 2, positions 1, 3, and 4 contain their own indices. The output is 1 3 4.

Input format

The first line contains n. The second line contains n space-separated integers.

Output format

Print matching one-based indices separated by spaces, or NONE if none match.

Constraints

1 <= n <= 100000; -1000000000 <= a[i] <= 1000000000.

Sample input

5
1 8 3 4 2

Sample output

1 3 4

Sign in to run or submit a solution in C++, Java or Python.