#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ara[n + 5], ar[n + 5];
  ar[0] = INT_MAX;
  int j = 1, i, a = 0, b = 1;
  for (i = 1; i <= n; ++i) {
    cin >> ara[i];
    if (ara[i] == 0) ar[j++] = i;
  }
  ar[j] = INT_MAX;
  for (i = 1; i <= n; ++i) {
    int temp = min(abs(ar[a] - i), abs(ar[b] - i));
    cout << temp << " ";
    if (ara[i] == 0) ++a, ++b;
  }
  return 0;
}
