#K36697. Distributing Gold Coins

    ID: 25812 Type: Default 1000ms 256MiB

Distributing Gold Coins

Distributing Gold Coins

You are given an integer \(n\), representing the number of citizens, and an array \(targets\) of length \(n\) where the \(i\)-th element \(targets[i]\) (0-indexed) indicates the number of gold coins citizen \(i+1\) should receive.

The coin distribution system is able to give at most one coin to any citizen. Thus, if any \(targets[i] > 1\), a valid distribution is impossible. Otherwise, the valid distribution is to give a coin to each citizen for which \(targets[i] = 1\), and output their 1-indexed positions.

Your task is to print the positions of the citizens who receive a coin, separated by a space. If a valid distribution is impossible or no citizen receives a coin, print an empty output.

inputFormat

The first line contains a single integer \(n\) (\(1 \leq n \leq 10^5\)), representing the number of citizens.

The second line contains \(n\) space-separated integers, where the \(i\)-th integer is \(targets[i]\) (\(0 \leq targets[i] \leq 10^9\)).

outputFormat

If a valid distribution is possible, output a single line containing the 1-indexed positions of citizens who receive a coin, separated by spaces. If not, output an empty line.

## sample
5
1 0 2 1 0