#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 1ll << 60;
const int mod = 1e9 + 7;
int n, a[200010], b[200010];
int main() {
  b[0] = INF;
  cin >> n;
  int len = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 0) b[++len] = i;
  }
  b[len + 1] = INF;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0)
      cout << 0 << " ";
    else {
      int l = 1, r = len;
      while (l < r) {
        int mid = l + r >> 1;
        if (i <= b[mid])
          r = mid;
        else
          l = mid + 1;
      }
      cout << min(abs(i - b[r + 1]), min(abs(i - b[r - 1]), abs(i - b[r])))
           << " ";
    }
  }
  cout << endl;
  return 0;
}
