#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> dist(n, 999999);
  dist[0] = a[0] ? dist[0] : 0;
  for (int i = 1; i < n; ++i) dist[i] = a[i] ? dist[i - 1] + 1 : 0;
  dist[n - 1] = a[n - 1] ? dist[n - 1] : 0;
  for (int i = n - 2; i >= 0; --i)
    dist[i] = min(dist[i], a[i] ? dist[i + 1] + 1 : 0);
  for (int i = 0; i < n; ++i) cout << dist[i] << " ";
}
