#include <bits/stdc++.h>
using namespace std;
int abs(int a) {
  if (a < 0) return -a;
  return a;
}
vector<int> null;
int n;
int lower_bound(int a) {
  int l = 0, r = null.size() - 1;
  while (l < r) {
    int m = (l + r) / 2;
    if (null[m] >= a)
      r = m;
    else
      l = m + 1;
  }
  return l;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int e;
    cin >> e;
    if (e == 0) null.push_back(i);
  }
  for (int i = 0; i < n; i++) {
    int second = lower_bound(i), first;
    if (second > 0) {
      first = null[second - 1];
      second = null[second];
    } else {
      first = 1e9;
      second = null[second];
    }
    cout << min(abs(i - first), abs(i - second)) << " ";
  }
  return 0;
}
