#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> dl(n, -INF);
  vector<int> dr(n, INF);
  int bef_idx = -INF;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) bef_idx = i;
    dl[i] = bef_idx;
  }
  bef_idx = INF;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) bef_idx = i;
    dr[i] = bef_idx;
  }
  for (int i = 0; i < n; i++) {
    int dist = min(i - dl[i], dr[i] - i);
    if (i != n - 1)
      cout << dist << " ";
    else
      cout << dist << "\n";
  }
}
