#include <bits/stdc++.h>
using namespace std;
inline void readi(int& a) { scanf("%d", &a); }
int main() {
  int n;
  readi(n);
  int a[n], d[n], last_zero_index = -INT_MAX / 2;
  for (int i = 0; i < n; ++i) {
    readi(a[i]);
    if (0 == a[i]) {
      last_zero_index = i;
    }
    d[i] = i - last_zero_index;
  }
  last_zero_index = INT_MAX / 2;
  for (int i = n - 1; i >= 0; --i) {
    if (0 == a[i]) {
      last_zero_index = i;
    }
    int new_d = last_zero_index - i;
    if (new_d < d[i]) {
      d[i] = new_d;
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d ", d[i]);
  }
  printf("\n");
  return 0;
}
