#C2838. Array Transformation: Position By Value

    ID: 46198 Type: Default 1000ms 256MiB

Array Transformation: Position By Value

Array Transformation: Position By Value

You are given an integer array A with size n. Your task is to transform this array into a new array B of the same size based on the following rule:

For each element a in A, if it satisfies

[ 0 \leq a < n ]

then set B[a] = a. Otherwise, leave B at that index as -1. Initially, all positions of B are set to -1.

Note: If an index appears more than once, simply assign it on the first (or any) valid occurrence, as the result remains the same.

For example, consider the array: [2, 0, 3, 5, -4, 1]. The transformed array will be [0, 1, 2, 3, -1, 5].

inputFormat

The input is given via standard input and consists of two lines:

  • The first line contains a single integer n which represents the number of elements in the array.
  • The second line contains n space-separated integers representing the elements of the array A.

outputFormat

Output the transformed array B on a single line as space-separated integers. If the array is empty, output nothing.

## sample
6
2 0 3 5 -4 1
0 1 2 3 -1 5