#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
int n, m;
int a[MAX], b[MAX];
int i, j, k, t;
void init() {
  k = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) b[k++] = i;
  }
  b[k] = b[k - 1];
}
int main() {
  while (~scanf("%d", &n)) {
    init();
    int x = 0;
    for (i = 0; i < n; i++) {
      if (abs(i - b[x]) < abs(i - b[x + 1]))
        a[i] = abs(i - b[x]);
      else {
        a[i] = abs(i - b[x + 1]);
        if (x < k - 1) x++;
      }
      printf("%d ", a[i]);
    }
    printf("\n");
  }
  return 0;
}
