#include <bits/stdc++.h>
using namespace std;
struct Amocana_A {
  void solve() {
    int n;
    cin >> n;
    vector<int> zs;
    vector<int> v(n);
    for (int i = int(0); i < int(n); i++) {
      cin >> v[i];
      if (v[i] == 0) zs.push_back(i);
    }
    vector<int> ans(n, INT_MAX);
    int c = 0;
    for (int i = int(zs[0]); i < int(n); i++) {
      if (v[i] == 0) c = 0;
      ans[i] = min(c, ans[i]);
      c++;
    }
    c = 0;
    for (int i = int(zs[zs.size() - 1]); i >= int(0); i--) {
      if (v[i] == 0) c = 0;
      ans[i] = min(c, ans[i]);
      c++;
    }
    for (int i = int(0); i < int(n); i++) cout << ans[i] << " ";
    cout << endl;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Amocana_A solver;
  solver.solve();
  return 0;
}
