#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  scanf("%d", &n);
  long arr[n];
  vector<int> zero;
  for (long long i = 0; i < n; ++i) {
    scanf("%ld", &arr[i]);
    if (arr[i] == 0) zero.push_back(i);
  }
  int index = 0, c = 0;
  int si = zero.size(), start = n;
  for (long long i = 0; i < n; ++i) {
    if (index == 0 && i < zero[index]) {
      printf("%lld ", zero[index] - i);
    } else if (i == zero[index]) {
      printf("0 ");
      index++;
      if (index == si) {
        start = i;
        break;
      }
    } else {
      printf("%lld ", min(abs(zero[index - 1] - i), abs(zero[index] - i)));
    }
  }
  for (long long i = start + 1; i < n; ++i) {
    printf("%lld ", i - zero[index - 1]);
  }
}
int main() {
  bool testing = false;
  if (testing) {
    freopen("test.txt", "rt", stdin);
    int start = clock();
    solve();
    int end = clock();
    cout << "time: " << (end - start) / (double)(CLOCKS_PER_SEC)*1000
         << " milliseconds\n";
  } else {
    solve();
  }
}
