You are given the array of integer numbers a0, a1, ..., an - 1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — length of the array a. The second line contains integer elements of the array separated by single spaces ( - 109 ≤ ai ≤ 109).

Output

Print the sequence d0, d1, ..., dn - 1, where di is the difference of indices between i and nearest j such that aj = 0. It is possible that i = j.

Examples

Input

9
2 1 0 3 0 0 3 2 4


Output

2 1 0 1 0 0 1 2 3 

Input

5
0 1 2 3 4


Output

0 1 2 3 4 

Input

7
5 6 0 1 -2 3 4


Output

2 1 0 1 2 3 4 
#include <bits/stdc++.h>
using namespace std;
const long long inf = LLONG_MAX;
const long long mod = 1000000007;
long long gcd(long long a, long long b) {
  if (!a || !b) return a | b;
  unsigned shift = __builtin_ctz(a | b);
  a >>= __builtin_ctz(a);
  do {
    b >>= __builtin_ctz(b);
    if (a > b) swap(a, b);
    b -= a;
  } while (b);
  return a << shift;
}
long long gcd(long long a, long long b, long long& x, long long& y) {
  x = 1, y = 0;
  long long x1 = 0, y1 = 1, a1 = a, b1 = b;
  while (b1) {
    long long q = a1 / b1;
    tie(x, x1) = make_tuple(x1, x - q * x1);
    tie(y, y1) = make_tuple(y1, y - q * y1);
    tie(a1, b1) = make_tuple(b1, a1 - q * b1);
  }
  return a1;
}
long long bits(long long x) {
  long long res = 0;
  while (x) {
    x = (x >> 1);
    res++;
  }
  return res;
}
long long power(long long x, long long y, long long p) {
  if (!y) return 1;
  long long z = power(x, y / 2, p);
  z = (z * z) % p;
  if (y % 2) z = (z * x) % p;
  return z;
}
class bit {
 private:
  long long n;
  vector<long long> t;

 public:
  bit() {}
  bit(long long init) {
    n = init;
    t.assign(init + 1, 0);
  }
  long long sum(long long r) {
    long long ans = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ans += t[r];
    return ans;
  }
  void update(long long i, long long delta) {
    for (; i < n; i = i | (i + 1)) t[i] += delta;
  }
  void range_update(long long l, long long r, long long x) {
    update(l, x);
    update(r + 1, -x);
  }
  long long point_query(long long i) { return sum(i); }
};
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n), l(n, -1), r(n, -1);
  for (long long i = (0); i < (n); i++) {
    cin >> a[i];
    if (!a[i]) l[i] = r[i] = i;
  }
  for (long long i = (1); i < (n); i++) {
    if (l[i] < 0) l[i] = l[i - 1];
  }
  for (long long i = (n - 1); i >= (0); --i) {
    if (r[i] < 0) r[i] = r[i + 1];
  }
  for (long long i = (0); i < (n); i++) {
    if (l[i] < 0)
      cout << abs(i - r[i]) << " ";
    else if (r[i] < 0)
      cout << abs(i - l[i]) << " ";
    else
      cout << min(abs(i - r[i]), abs(i - l[i])) << " ";
  }
  cout << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
