#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  int m = INT_MAX;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) m = i;
    b[i] = m;
  }
  m = INT_MAX;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) m = i;
    c[i] = m;
  }
  for (int i = 0; i < n; i++) {
    int pr;
    pr = min(abs(i - b[i]), abs(i - c[i]));
    cout << pr << " ";
  }
  return 0;
}
