#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ind = -1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    if (tmp == 0) {
      if (ind == -1) {
        for (int j = 0; j <= i; j++) {
          printf("%d ", i - j);
        }
        ind = i;
      } else {
        for (int j = ind + 1; j <= i; j++) {
          printf("%d ", min(i - j, j - ind));
        }
        ind = i;
      }
    } else if (i == n - 1) {
      for (int j = ind + 1; j < n; j++) {
        printf("%d ", j - ind);
      }
    }
  }
  return 0;
}
