#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q;
  cin >> q;
  vector<long long> v(q);
  int t = -1;
  for (long long x = 0; x < q; x++) {
    cin >> v[x];
    if (v[x] == 0 && t == -1) t = x;
  }
  for (long long x = 0; x < q; x++) {
    if (v[x] == 0) t = x;
    v[x] = abs(t - x);
  }
  for (long long x = q - 1; x >= 0; x--) {
    if (v[x] == 0) t = x;
    v[x] = min(abs(t - x), v[x]);
  }
  for (int x = 0; x < q; x++) cout << v[x] << " ";
  return 0;
}
