#d11405. Nearest Opposite Parity

Nearest Opposite Parity

Nearest Opposite Parity

Problem Description

Given an array aa of length nn indexed from 11. From position ii you can move to position i−aii - a_i (if 1≤i−ai1 \le i - a_i) or i+aii + a_i (if i+ai≤ni + a_i \le n).

For each position ii (1≤i≤n1 \le i \le n), find the minimum number of steps to reach some position jj such that ai mod 2≠aj mod 2a_i \bmod 2 \neq a_j \bmod 2. If no such position jj exists, output -1.

Input Format

The first line contains an integer nn (1≤n≤2×1051 \le n \le 2 \times 10^5), the length of the array.

The second line contains nn integers aia_i (1≤ai≤n1 \le a_i \le n), the given array.

Output Format

Output one line containing nn integers, where the jj-th integer is the answer starting from position jj.

Sample Input

10
4 5 7 6 7 5 4 4 6 4

Sample Output

1 1 1 2 -1 1 1 3 1 1