#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
const int mod = 1e9 + 7;
int a[N], f[N];
int main() {
  int n;
  int p = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) f[p++] = i;
  }
  int v = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != 0) {
      a[i] = abs(f[v] - i);
      if (v + 1 < p) a[i] = min(a[i], abs(f[v + 1] - i));
      if (v - 1 >= 0) a[i] = min(a[i], abs(f[v - 1] - i));
    } else
      v++;
  }
  printf("%d", a[0]);
  for (int i = 1; i < n; i++) {
    printf(" %d", a[i]);
  }
  return 0;
}
