#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n);
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 0) a.push_back(i);
  }
  for (long long i = 0; i < n; i++) {
    long long k = upper_bound(a.begin(), a.end(), i) - a.begin();
    long long ans = abs(i - a[k]);
    if (k > 0) {
      ans = min(ans, abs(i - a[k - 1]));
    }
    cout << ans << " ";
  }
}
