#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 20, INF = 1e9;
int n, num[maxn], l, r, pre[maxn], low[maxn];
int main() {
  while (~scanf("%d", &n)) {
    l = r = -1;
    for (int i = 0; i < n; i++) scanf("%d", &num[i]);
    for (int i = 0; i < n; i++) {
      if (num[i] == 0) l = i;
      if (l == -1)
        pre[i] = INF;
      else
        pre[i] = i - l;
    }
    for (int i = n - 1; i >= 0; i--) {
      if (num[i] == 0) r = i;
      if (r == -1)
        low[i] = INF;
      else
        low[i] = r - i;
    }
    for (int i = 0; i < n; i++)
      printf("%d%c", min(pre[i], low[i]), i == n - 1 ? '\n' : ' ');
  }
  return 0;
}
