#include <bits/stdc++.h>
using namespace std;
long long a[200005];
int main() {
  int n;
  cin >> n;
  vector<int> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      s.push_back(i);
    }
  }
  long long i = 0, j = 0;
  while (i < n) {
    if (abs(i - s[j]) > abs(i - s[j + 1])) {
      if (j != s.size() - 1) {
        j++;
      }
    }
    cout << abs(i - s[j]) << " ";
    i++;
  }
}
