#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
template <typename T>
void cins(T &first) {
  cin >> first;
}
template <typename T, typename... Ts>
void cins(T &first, T &second, Ts &...rest) {
  cin >> first;
  cins(second, rest...);
}
const long long mod = pow(10, 9) + 7;
const long long N = 3e5, M = N;
const long long inf = LLONG_MAX;
const long long infn = LLONG_MIN;
void iluzn() {
  long long n;
  cins(n);
  vector<long long> a(n);
  vector<long long> dis(n, inf);
  long long l = -1, r;
  for (long long i = 0; i < (long long)n; i += 1) {
    cin >> a[i];
    if (!a[i]) {
      dis[i] = 0;
      if (l == -1) l = i;
      r = i;
    }
  }
  long long cd = 0;
  for (long long i = l + 1; i < (long long)n; i += 1) {
    ++cd;
    if (!dis[i]) {
      cd = 0;
    }
    dis[i] = min(dis[i], cd);
  }
  cd = 0;
  for (long long i = r - 1; i >= (long long)0; i -= 1) {
    ++cd;
    if (!dis[i]) cd = 0;
    dis[i] = min(dis[i], cd);
  }
  for (long long i = 0; i < (long long)n; i += 1) cout << dis[i] << " ";
}
signed main() {
  long long t = 1;
  while (t--) iluzn();
  return 0;
}
