#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(n, 1000000000);
  vector<int> vb(n, 1000000000);
  vector<long long> a(n);
  long long prev = 1000000000;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i] == 0) prev = i;
    v[i] = prev;
  }
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] == 0) prev = i;
    vb[i] = prev;
  }
  for (int i = 0; i < n; ++i) {
    printf("%d ", min((int)abs(v[i] - i), (int)abs(vb[i] - i)));
  }
  printf("\n");
}
