#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  auto a = vector<int>(n);
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    if (a[i]) a[i] = 1000000;
  }
  for (int i = 1; i < n; ++i) {
    auto j = n - 1 - i;
    a[i] = min(a[i], a[i - 1] + 1);
    a[j] = min(a[j], a[j + 1] + 1);
  }
  for (auto e : a) cout << e << ' ';
  cout << '\n';
  return 0;
}
