#include <bits/stdc++.h>
using namespace std;
long long int a[200005];
long long int dist[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) dist[i] = INT_MAX;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int m = INT_MAX;
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 0) {
      m = i;
      dist[i] = 0;
    }
    if (m == INT_MAX) {
      dist[i] = INT_MAX;
      continue;
    }
    dist[i] = min(dist[i], i - m);
  }
  m = INT_MAX;
  for (long long int i = n - 1; i > -1; i--) {
    if (a[i] == 0) {
      m = i;
      dist[i] = 0;
    }
    dist[i] = min(dist[i], m - i);
  }
  for (long long int i = 0; i < n; i++) cout << dist[i] << " ";
  return 0;
}
