#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n;
long long a[N];
set<long long> s;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (!a[i]) s.insert(i);
  }
  for (long long i = 1; i <= n; i++) {
    auto it = s.lower_bound(i);
    long long ans = n;
    if (it != s.end()) ans = min(ans, *it - i);
    if (it != s.begin()) {
      it--;
      ans = min(ans, i - *it);
    }
    cout << ans << " ";
  }
  return 0;
}
