#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans[n];
  for (int i = 0; i < n; i++) ans[i] = 1000000007;
  int ind = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      ind = i;
      ans[i] = 0;
    } else if (ind != -1) {
      ans[i] = min(abs(ind - i), ans[i]);
    }
  }
  ind = -1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      ind = i;
      ans[i] = 0;
    } else if (ind != -1) {
      ans[i] = min(abs(ind - i), ans[i]);
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
