#include <bits/stdc++.h>
using namespace std;
int a[200001], b1[200001], c1[200001];
int main() {
  register int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int p1 = -1, p2 = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      p1 = i;
      b1[i] = 0;
      continue;
    }
    if (p1 != (-1))
      b1[i] = i - p1;
    else
      b1[i] = 0x7fffffff;
  }
  for (int i = n; i >= 1; i--) {
    if (a[i] == 0) {
      p2 = i;
      c1[i] = 0;
      continue;
    }
    if (p2 != (-1))
      c1[i] = p2 - i;
    else
      c1[i] = 0x7fffffff;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", min(b1[i], c1[i]));
  }
  printf("\n");
  return 0;
}
