#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  vector<int> prawo, lewo;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
    prawo.push_back(0);
    lewo.push_back(0);
  }
  int ost_zero = 1000000;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      ost_zero = 0;
      prawo[i] = 0;
    } else {
      prawo[i] = ++ost_zero;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      ost_zero = 0;
      lewo[i] = 0;
    } else {
      lewo[i] = ++ost_zero;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << min(lewo[i], prawo[i]) << " ";
  }
  return 0;
}
