#include <bits/stdc++.h>
using namespace std;
int a[213123];
int d[223123];
int n;
int main() {
  cin.tie();
  cout.tie();
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d[i] = 1e9;
  }
  int l = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0)
      l = i;
    else if (l != -1) {
      d[i] = i - l;
    }
  }
  int r = -1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0)
      r = i;
    else if (r != -1) {
      if (d[i] == -1)
        d[i] = r;
      else
        d[i] = min(d[i], r - i);
    }
  }
  for (int i = 0; i < n; i++) {
    if (d[i] != 1e9)
      cout << d[i] << " ";
    else
      cout << 0 << " ";
  }
  return 0;
}
