#include <bits/stdc++.h>
using namespace std;
const int INF = 200050;
int a[INF], zero[INF];
int judge(int n, int k, int num) {
  int r1 = -1, r2 = -1;
  int r = lower_bound(zero, zero + k, num) - zero;
  if (r == 0) {
    return abs(zero[0] - num);
  }
  r1 = abs(zero[r - 1] - num);
  r2 = abs(zero[r] - num);
  if (r1 > r2) r1 = r2;
  return r1;
  return r1;
}
int main() {
  int n, k = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) zero[k++] = i;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0)
      printf("0 ");
    else
      printf("%d ", judge(n, k, i));
  }
  printf("\n");
  return 0;
}
