#include <bits/stdc++.h>
using namespace std;
int n, ans[200010], pos, x, oo = -1000000005;
bool b = false;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 0) {
      ans[i] = 0;
      pos = 0;
      b = true;
    } else {
      if (pos > 0 && b)
        ans[i] = pos;
      else
        ans[i] = oo;
    }
    pos++;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (ans[i] == 0)
      pos = 0;
    else if (ans[i] == oo)
      ans[i] = pos;
    else if (pos < ans[i])
      ans[i] = pos;
    pos++;
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
