#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<pair<T, T> > &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> arr(n + 1), zeroes;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    if (!arr[i]) {
      zeroes.push_back(i);
    }
  }
  int sz = zeroes.size();
  for (int i = 1; i <= n; ++i) {
    vector<int>::iterator low = lower_bound(zeroes.begin(), zeroes.end(), i);
    int dist = 1e9;
    vector<int>::iterator it;
    if (low == zeroes.begin())
      it = zeroes.begin();
    else {
      it = low - 1;
    }
    if (low == zeroes.end()) {
      dist = min(dist, abs(i - zeroes[sz - 1]));
    } else {
      for (int j = 0; j < 3 && it != zeroes.end(); ++j) {
        dist = min(dist, abs(i - *it));
        ++it;
      }
    }
    cout << dist << " ";
  }
  cout << "\n";
  return 0;
}
