#include <bits/stdc++.h>
using namespace std;
int a[200200];
int main() {
  int n, x;
  scanf("%d", &n);
  queue<int> q;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (!x) q.push(i);
  }
  int l, r, ind;
  ind = q.front();
  a[ind] = 0;
  for (int i = 0; i < ind; i++) a[i] = ind - i;
  while (q.size() > 1) {
    l = q.front();
    q.pop();
    r = q.front();
    a[l] = a[r] = 0;
    for (int i = l + 1; i <= (l + r) / 2; i++) a[i] = i - l;
    for (int i = r - 1; i > (l + r) / 2; i--) a[i] = r - i;
  }
  ind = q.front();
  q.pop();
  for (int i = ind + 1; i < n; i++) a[i] = i - ind;
  printf("%d", a[0]);
  for (int i = 1; i < n; i++) printf(" %d", a[i]);
  putchar('\n');
}
