#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int ans[MAXN];
int a[MAXN];
int main(int argc, char const *argv[]) {
  int N;
  while (scanf("%d", &N) != EOF) {
    int p = 0;
    for (int i = 0; i < N; i++) {
      scanf("%d", &a[i]);
    }
    for (int i = 0; i < N; i++) ans[i] = INF;
    if (a[0] == 0) ans[0] = 0;
    for (int i = 1; i < N; i++) {
      if (a[i] == 0)
        ans[i] = 0;
      else
        ans[i] = ans[i - 1] + 1;
    }
    if (a[N - 1] == 0) ans[N - 1] = 0;
    for (int i = N - 2; i >= 0; i--) {
      if (a[i] == 0)
        ans[i] = 0;
      else
        ans[i] = min(ans[i], ans[i + 1] + 1);
    }
    printf("%d", ans[0]);
    for (int i = 1; i < N; i++) {
      printf(" %d", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
