#include <bits/stdc++.h>
int a[200005], pre[200005], suf[200005];
int mini(int x, int y) {
  if (x <= y) return x;
  return y;
}
int main() {
  int n;
  scanf("%d", &n);
  int i;
  int pr = -1000000;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) pr = i;
    pre[i] = pr;
  }
  pr = 1000000;
  for (i = n; i >= 1; i--) {
    if (a[i] == 0) pr = i;
    suf[i] = pr;
  }
  for (i = 1; i <= n; i++) printf("%d ", mini(i - pre[i], suf[i] - i));
  return 0;
}
