#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n;
int a[N], f[N];
queue<int> q;
int main() {
  scanf("%d", &n);
  for (int i(1); i <= (n); ++i) {
    scanf("%d", a + i);
    if (a[i] == 0) {
      q.push(i);
      f[i] = 1;
    }
  }
  f[0] = f[n + 1] = 1e9;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    if (f[t - 1] == 0) q.push(t - 1), f[t - 1] = f[t] + 1;
    if (f[t + 1] == 0) q.push(t + 1), f[t + 1] = f[t] + 1;
  }
  for (int i(1); i <= (n); ++i) printf("%d ", f[i] - 1);
  return 0 * putchar(10);
}
