#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int *a = new long long int[n];
  vector<int> zero;
  int l = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      zero.push_back(i);
      l = l + 1;
    }
  }
  vector<int>::iterator it1;
  vector<int>::iterator it2;
  sort(zero.begin(), zero.end());
  for (int i = 0; i < n; i++) {
    it1 = lower_bound(zero.begin(), zero.end(), i);
    if (it1 != zero.end()) {
      if (it1 == zero.begin()) {
        cout << (abs(i - (*it1))) << " ";
      } else {
        int ans1 = abs(i - (*it1));
        int ans2 = abs(i - zero[it1 - zero.begin() - 1]);
        cout << (min(ans1, ans2)) << " ";
      }
    } else {
      int ans2 = abs(i - zero[l - 1]);
      cout << (ans2) << " ";
    }
  }
}
