#include <bits/stdc++.h>
using namespace std;
int main() {
  int s = 1e9, n;
  int a[222222] = {0};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] != 0) a[i] = 1e9;
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 0)
      s = 0;
    else {
      s++;
      a[i] = min(a[i], s);
    }
  }
  s = 1e9;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] == 0)
      s = 0;
    else {
      s++;
      a[i] = min(a[i], s);
    }
  }
  for (int i = 0; i < n; ++i) cout << a[i] << ' ';
  cout << endl;
  return 0;
}
