#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp;
  scanf("%d", &n);
  int arr[n + 1], left[n + 1], right[n + 1];
  memset(left, 999999, sizeof(left));
  memset(right, 999999, sizeof(right));
  for (int i = 0; i < n; i++) {
    scanf("%d", &temp);
    if (temp != 0)
      arr[i] = 9;
    else
      arr[i] = 0;
  }
  if (arr[0] == 0) left[0] = 0;
  for (int i = 1; i < n; i++) {
    if (arr[i] != 0)
      left[i] = left[i - 1] + 1;
    else
      left[i] = 0;
  }
  if (arr[n - 1] == 0) right[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (arr[i] != 0)
      right[i] = right[i + 1] + 1;
    else
      right[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", min(left[i], right[i]));
  }
  return 0;
}
