#include <bits/stdc++.h>
using namespace std;
vector<int> zeroes;
int binarySearch(int p, int low, int high) {
  int ans = INT_MAX;
  while (low <= high) {
    int mid = (low + high) >> 1;
    ans = min(ans, abs(p - zeroes[mid]));
    if (zeroes[mid] > p) {
      high = mid - 1;
    } else if (zeroes[mid] < p) {
      low = mid + 1;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<long long int> v(n), result(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 0) {
      zeroes.emplace_back(i);
      result[i] = 0;
    } else {
      result[i] = -1;
    }
  }
  sort((zeroes).begin(), (zeroes).end());
  int len = (int)zeroes.size();
  for (int i = 0; i < n; i++) {
    if (result[i] == -1) {
      result[i] = binarySearch(i, 0, len - 1);
    }
  }
  for (int x : result) {
    cout << x << " ";
  }
}
