#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> v(n), zero;
  for (long long int i = 0; i < (n); i++) {
    cin >> v[i];
  }
  long long int ind = INT_MIN;
  for (long long int i = 0; i < n; i++) {
    if (v[i] == 0) {
      ind = i;
    }
    v[i] = (abs(ind - i));
  }
  ind = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    if (v[i] == 0) {
      ind = i;
    }
    v[i] = min(v[i], abs(ind - i));
  }
  for (auto i : v) {
    cout << i << " ";
  }
  return 0;
}
