You are given an array a consisting of n integers. In one move, you can jump from the position i to the position i - a_i (if 1 ≤ i - a_i) or to the position i + a_i (if i + a_i ≤ n).

For each position i from 1 to n you want to know the minimum the number of moves required to reach any position j such that a_j has the opposite parity from a_i (i.e. if a_i is odd then a_j has to be even and vice versa).

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in a.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n), where a_i is the i-th element of a.

Output

Print n integers d_1, d_2, ..., d_n, where d_i is the minimum the number of moves required to reach any position j such that a_j has the opposite parity from a_i (i.e. if a_i is odd then a_j has to be even and vice versa) or -1 if it is impossible to reach such a position.

Example

Input


10
4 5 7 6 7 5 4 4 6 4


Output


1 1 1 2 -1 1 1 3 1 1 
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
void read(T &res) {
  bool flag = false;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (flag = true);
  for (res = ch - 48; isdigit(ch = getchar());
       res = (res << 1) + (res << 3) + ch - 48)
    ;
  flag && (res = -res);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long qp(long long a, long long b, long long mod) {
  long long ans = 1;
  if (b == 0) {
    return ans % mod;
  }
  while (b) {
    if (b % 2 == 1) {
      b--;
      ans = ans * a % mod;
    }
    a = a * a % mod;
    b = b / 2;
  }
  return ans % mod;
}
long long qpn(long long a, long long b, long long p) {
  long long ans = 1;
  a %= p;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % p;
      --b;
    }
    a = (a * a) % p;
    b >>= 1;
  }
  return ans % p;
}
const long long manx = 2e6 + 5;
const long long mamx = 4e6 + 5;
long long head[manx], d[manx], hurt[manx];
bool vis[manx];
long long n, m, k = 0, e, kk;
struct node {
  long long v, next, w;
} a[mamx];
void add(long long u, long long v, long long w) {
  a[++k].next = head[u];
  a[k].w = w;
  a[k].v = v;
  head[u] = k;
}
void dij(long long s) {
  for (long long i = 1; i <= n + 2; i++) {
    d[i] = 0x3f3f3f3f;
  }
  memset(vis, 0, sizeof(vis));
  d[s] = 0;
  priority_queue<pair<long long, long long> > q;
  q.push(make_pair(0, s));
  while (q.size()) {
    long long u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (long long i = head[u]; i; i = a[i].next) {
      long long v = a[i].v, w = a[i].w;
      if (d[v] > d[u] + w) {
        d[v] = d[u] + w;
        q.push(make_pair(-d[v], v));
      }
    }
  }
}
long long wtf[666666];
long long ans[666666];
signed main() {
  read(n);
  e = n + 2;
  for (long long i = 1; i <= n; i++) {
    read(wtf[i]);
    long long ok = i + wtf[i];
    long long ob = i - wtf[i];
    if (1 <= ok && ok <= n) {
      add(ok, i, 1);
    }
    if (1 <= ob && ob <= n) {
      add(ob, i, 1);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (wtf[i] % 2 != 0) {
      add(0, i, 0);
    } else {
      add(n + 1, i, 0);
    }
  }
  dij(0);
  for (long long i = 1; i <= n; i++) {
    if (d[i] != 0x3f3f3f3f && wtf[i] % 2 == 0) {
      ans[i] = d[i];
    }
  }
  dij(n + 1);
  for (long long i = 1; i <= n; i++) {
    if (d[i] != 0x3f3f3f3f && wtf[i] % 2 != 0) {
      ans[i] = d[i];
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (!ans[i]) {
      printf("-1 ");
    } else {
      printf("%lld ", ans[i]);
    }
  }
  return 0;
}
