#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 2];
  int x, cnt = 10000000;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 0) cnt = 0;
    arr[i] = cnt;
    cnt++;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] == 0) cnt = 0;
    if (arr[i] > cnt) arr[i] = cnt;
    cnt++;
  }
  for (int i = 0; i < n; i++) printf("%d ", arr[i]);
}
