#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], tmp[n], b1[n], b2[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(b1, 127, sizeof b1);
  memset(b2, 127, sizeof b2);
  int k = 0;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      v.push_back(i);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    k = 0;
    for (int j = v[i] + 1; j < n && a[j] != 0; j++) {
      b1[j] = ++k;
    }
  }
  for (int i = 0; i < v.size(); i++) {
    k = 0;
    for (int j = v[i] - 1; j >= 0 && a[j] != 0; j--) {
      b2[j] = ++k;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0)
      tmp[i] = 0;
    else
      tmp[i] = min(b1[i], b2[i]);
  }
  for (int i = 0; i < n; i++) cout << tmp[i] << " ";
  cout << '\n';
}
