#include <bits/stdc++.h>
using namespace std;
const int N = 200007;
vector<long long int> vec;
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, a[N], i, ans, s;
  scanf("%lld", &n);
  for (long long int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] == 0) vec.push_back(i);
  }
  for (long long int i = 0; i < n; i++) {
    if (a[i] != 0) {
      s = lower_bound(vec.begin(), vec.end(), i) - vec.begin();
      if (s >= vec.size())
        cout << abs(vec[s - 1] - i) << " ";
      else if (s == 0)
        cout << abs(vec[s] - i) << " ";
      else
        cout << min(abs(vec[s] - i), abs(vec[s - 1] - i)) << " ";
    } else
      cout << "0 ";
  }
  cout << "\n";
  return 0;
}
