#include <bits/stdc++.h>
const int N = 200005;
using namespace std;
int n, a[N], b[N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  memset(b, -1, sizeof b);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!a[i]) b[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (!b[i]) {
      for (int l = i - 1; l >= 0; l--)
        if (b[l] == -1) {
          b[l] = i - l;
        } else if (i - l < b[l])
          b[l] = i - l;
        else
          break;
      for (int r = i + 1; r < n; r++)
        if (b[r] == -1)
          b[r] = r - i;
        else if (r - i < b[r])
          b[r] = r - i;
        else
          break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i) cout << ' ';
    cout << b[i];
  }
  cout << '\n';
  return 0;
}
