#include <bits/stdc++.h>
using namespace std;
int n, a[202020], d[202020];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    d[i] = 202020 + 202020;
  }
  for (int i = 0, l = -202020; i < n; i++) {
    if (a[i] == 0) l = i;
    d[i] = min(d[i], i - l);
  }
  for (int i = n - 1, r = n + 202020; i >= 0; i--) {
    if (a[i] == 0) r = i;
    d[i] = min(d[i], r - i);
  }
  for (int i = 0; i < n; i++) printf("%d%c", d[i], " \n"[i + 1 == n]);
}
