#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, ara[300010], i, j, k, y, arr[300010];
  while (scanf("%d", &n) == 1) {
    x = 0;
    int flag = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &ara[i]);
    }
    for (i = 0; i <= n; i++) {
      if (ara[i] == 0) {
        arr[i] = 0;
        if (flag == 0) {
          flag = 1;
          y = 1;
          for (j = i - 1; j >= 0; j--) arr[j] = y++;
        } else if (i == n) {
          y = 1;
          for (j = x + 1; j < n; j++) arr[j] = y++;
        } else {
          y = 1;
          for (j = x + 1, k = i - 1; j <= (x + i) / 2; j++, k--) {
            arr[j] = y;
            arr[k] = y++;
          }
        }
        x = i;
      }
    }
    for (i = 0; i < n; i++) printf("%d ", arr[i]);
    printf("\n");
  }
  return 0;
}
