#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int arr[N], res[N];
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      v.push_back(i);
    }
  }
  for (int i = 0, j = 0; i < n; i++) {
    if (j < v.size() - 1) {
      if (i == v[j + 1]) {
        res[i] = 0;
        j++;
      } else
        res[i] = min(abs(v[j] - i), abs(v[j + 1] - i));
    } else
      res[i] = abs(i - v[j]);
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] << ' ';
  }
  cout << '\n';
  return 0;
}
