#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long n;
  cin >> n;
  vector<long> a(n);
  vector<long> zeros;
  for (long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) zeros.push_back(i);
  }
  vector<long> ans;
  for (long i = 0; i < n; i++) {
    long x = lower_bound(zeros.begin(), zeros.end(), i) - zeros.begin();
    if (x == 0)
      ans.push_back(zeros[x] - i);
    else if (x == zeros.size())
      ans.push_back(i - zeros[x - 1]);
    else
      ans.push_back(min(zeros[x] - i, i - zeros[x - 1]));
  }
  for (long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
