#include <bits/stdc++.h>
using namespace std;
vector<long long> zr;
long long bin(long long low, long long high, long long x) {
  if (low > high) return 0;
  long long mid = (low + high) >> 1;
  if (zr[mid] <= x && zr[mid + 1] > x) {
    return mid;
  } else if (zr[mid] <= x) {
    return bin(mid + 1, high, x);
  } else {
    return bin(low, mid - 1, x);
  }
}
int main() {
  long long n;
  while (cin >> n) {
    vector<long long> v;
    v.clear();
    long long u;
    long long ans = -1;
    for (int i = 0; i < n; ++i) cin >> u, v.push_back(u);
    zr.clear();
    zr.push_back(-1ll << 60);
    for (int i = 0; i < n; ++i)
      if (v[i] == 0) zr.push_back(i);
    zr.push_back(1ll << 60);
    long long sz = zr.size();
    long long b = bin(0, sz - 1, 0);
    cout << min(abs(zr[b] - 0), abs(zr[b + 1] - 0));
    for (int k = 1; k < n; ++k) {
      long long t = bin(0, sz - 1, k);
      cout << " " << min(abs(zr[t] - k), abs(zr[t + 1] - k));
    }
    cout << endl;
  }
  return 0;
}
