#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 5;
long long a[maxn];
long long pos[maxn], ans[maxn];
int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    if (!a[i]) pos[sum++] = i;
  }
  for (int i = 0; i <= pos[0]; ++i) printf("%lld ", pos[0] - i);
  int k = 1;
  for (int i = pos[0] + 1; i <= pos[sum - 1]; ++i) {
    if (i <= pos[k])
      printf("%lld ", min(i - pos[k - 1], pos[k] - i));
    else {
      k++;
      printf("%lld ", min(i - pos[k - 1], pos[k] - i));
    }
  }
  for (int i = pos[sum - 1] + 1; i < n; ++i) printf("%lld ", i - pos[sum - 1]);
  printf("\n");
  return 0;
}
