#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int arr[n];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  long long int left[n], right[n];
  for (int i = 0; i < n; ++i) {
    left[i] = 1000000;
    right[i] = 1000000;
  }
  int l = 1000000, r = 1000000;
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (arr[i] == 0) {
      left[i] = 0;
      l = i;
      count = 0;
    } else {
      if (l != 1000000) {
        count++;
        left[i] = count;
      }
    }
  }
  count = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (arr[i] == 0) {
      right[i] = 0;
      r = i;
      count = 0;
    } else {
      if (r != 1000000) {
        count++;
        right[i] = count;
      }
    }
  }
  for (int i = 0; i < n; ++i) cout << min(left[i], right[i]) << ' ';
  return 0;
}
