#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int v[n];
  for (int i = 0; i < n; i++) scanf("%d", v + i);
  int zero[n];
  int left = 2 * 1e9 + 1;
  for (int i = n - 1; i >= 0; i--) {
    if (v[i] == 0) left = i;
    zero[i] = left - i;
  }
  int right = -2 * 1e9 - 1;
  for (int i = 0; i < n; i++) {
    if (v[i] == 0) right = i;
    zero[i] = min(zero[i], i - right);
  }
  for (int i = 0; i < n; i++) printf("%d ", zero[i]);
  return 0;
}
