#include <bits/stdc++.h>
using namespace std;
int n, a[200010], b[200010];
void solve() {
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) b[j++] = i;
  }
  int t = j;
  int flag = 0, min_x, tem = 0;
  for (int i = 0; i < n; i++) {
    min_x = 1e10;
    if (flag == 0) {
      if (a[i] == 0)
        printf("0");
      else {
        for (int j = tem; j < t; j++) {
          if ((abs(b[j] - i)) < min_x) {
            min_x = abs(b[j] - i);
            tem = j;
          }
          if (abs(b[j] - i) > min_x) break;
        }
        printf("%d", min_x);
      }
      flag = 1;
    } else {
      if (a[i] == 0)
        printf(" 0");
      else {
        for (int j = tem; j < t; j++) {
          if ((abs(b[j] - i)) < min_x) {
            min_x = abs(b[j] - i);
            tem = j;
          }
          if (abs(b[j] - i) > min_x) break;
        }
        printf(" %d", min_x);
      }
    }
  }
  printf("\n");
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  solve();
  return 0;
}
