#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  int v[n + 5], st[n + 5], dr[n + 5];
  bool ok = false;
  for (i = 1; i <= n; i++) {
    cin >> v[i];
  }
  v[0] = -1;
  for (i = 1; i <= n; i++) {
    if (v[i] == 0) {
      st[i] = 0;
      ok = true;
    } else if (ok == true)
      st[i] = st[i - 1] + 1;
    else
      st[i] = -1;
  }
  ok = false;
  for (i = n; i >= 1; i--) {
    if (v[i] == 0) {
      dr[i] = 0;
      ok = true;
    } else if (ok == true)
      dr[i] = dr[i + 1] + 1;
    else
      dr[i] = -1;
  }
  for (i = 1; i <= n; i++) {
    if (st[i] == -1)
      cout << dr[i] << " ";
    else if (dr[i] == -1)
      cout << st[i] << " ";
    else if (st[i] <= dr[i])
      cout << st[i] << " ";
    else
      cout << dr[i] << " ";
  }
  return 0;
}
