#include <bits/stdc++.h>
using namespace std;
vector<int> v1, v2;
int a[200001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, j, k, l, y;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) v1.push_back(i);
  }
  j = v1.size();
  k = 0, l = 1;
  for (int i = 0; i < n; i++) {
    if (!a[i])
      v2.push_back(0);
    else {
      if (l == j)
        v2.push_back(abs(v1[k] - i));
      else if (v1[k] > i)
        v2.push_back(v1[k] - i);
      else if (v1[l] > i)
        v2.push_back(min(abs(v1[k] - i), (abs(v1[l] - i))));
      else
        i--, k++, l++;
    }
  }
  for (auto i : (v2)) cout << i << ' ';
  return 0;
}
