#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
void debugi(vector<int>& vec) {
  int n = (int)vec.size();
  for (int i = 0; i < n; i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<int> l(n), r(n);
  int last = -1;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0) {
      last = i;
    }
    l[i] = last;
  }
  last = -1;
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] == 0) {
      last = i;
    }
    r[i] = last;
  }
  vector<int> d(n, 1e8);
  for (int i = 0; i < n; i++) {
    if (l[i] != -1) {
      d[i] = min(d[i], i - l[i]);
    }
    if (r[i] != -1) {
      d[i] = min(d[i], r[i] - i);
    }
  }
  debugi(d);
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  for (int tt = 0; tt < t; tt++) {
    solve();
  }
  return 0;
}
