#include <bits/stdc++.h>
using namespace std;
int n;
int a[200001];
int l[200002];
int r[200002];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  l[0] = -1e6;
  r[n + 1] = 1e6;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      l[i] = i;
    } else {
      l[i] = l[i - 1];
    }
  }
  for (int i = n; i > 0; i--) {
    if (a[i] == 0) {
      r[i] = i;
    } else {
      r[i] = r[i + 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << min(i - l[i], r[i] - i) << (i != n ? ' ' : '\n');
  }
  return 0;
}
