#include <bits/stdc++.h>
const int maxn = 2 * 100000;
const int inf = 99999999;
class array {
 public:
  int num;
  int left;
  int right;
  array() { left = right = inf; }
} a[maxn + 1];
int queue[maxn + 1];
int head = 1, tail = 1;
int main() {
  int n;
  scanf("%d", &n);
  int nowzero = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].num);
    if (!a[i].num) {
      nowzero = i;
      a[i].left = a[i].right = 0;
      for (int j = head; j < tail; j++) {
        a[queue[j]].right = nowzero - queue[j];
      }
      tail = head;
    } else {
      if (nowzero) a[i].left = i - nowzero;
      queue[tail++] = i;
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d%c", a[i].left > a[i].right ? a[i].right : a[i].left,
           i == n ? '\n' : ' ');
  return 0;
}
