#include <bits/stdc++.h>
using namespace std;
const int maxn = 2123456;
int ans[maxn], a[maxn];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int last = -1000000;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) last = i;
    ans[i] = i - last;
  }
  last = 1000000;
  for (int i = n; i; i--) {
    if (a[i] == 0) last = i;
    ans[i] = min(ans[i], last - i);
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
