#include <bits/stdc++.h>
using namespace std;
vector<int> p, ans;
vector<int>::iterator lo, hi;
int n, a[200010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (!a[i]) p.push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    hi = upper_bound(p.begin(), p.end(), i);
    if (hi == p.begin()) {
      ans.push_back(*hi - i);
      continue;
    }
    lo = hi;
    --lo;
    if (hi == p.end()) {
      ans.push_back(i - *lo);
      continue;
    }
    ans.push_back(min(i - *lo, *hi - i));
  }
  for (int i = 0; i < n; ++i) printf("%d%c", ans[i], " \n"[i == n - 1]);
  return 0;
}
