#include <bits/stdc++.h>
using namespace std;
long long n, cnt, a[200005];
vector<long long> mv;
int main() {
  cin >> n;
  mv.push_back(-10000000000);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) mv.push_back(i);
  }
  mv.push_back(10000000000);
  for (long long i = 0; i < n; i++) {
    if (mv[cnt] < i) {
      cnt++;
    }
    cout << min(i - mv[cnt - 1], mv[cnt] - i) << " ";
  }
}
