#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i <= n - 1; i++) cin >> arr[i];
    int ans[n];
    int p = 300000;
    for (int i = 0; i < n; i++) {
      if (arr[i] == 0) p = 0;
      ans[i] = p;
      p++;
    }
    p = 300000;
    for (int i = n - 1; i >= 0; i--) {
      if (arr[i] == 0) p = 0;
      ans[i] = min(ans[i], p);
      p++;
    }
    for (int i = 0; i <= n - 1; i++) cout << ans[i] << " ";
  }
  return 0;
}
