#include <bits/stdc++.h>
using namespace std;
long long a[2 * 1000005], first_zero = 1e9, last_zero = 0;
struct node {
  long long id, left, right;
};
int main() {
  long long n, k;
  scanf("%I64d", &n);
  queue<long long> q;
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    if (a[i] == 0) {
      first_zero = min(i, first_zero);
      last_zero = max(i, last_zero);
      q.push(i);
    }
  }
  long long cnt = 0;
  for (int i = first_zero; i >= 0; i--) {
    a[i] = cnt++;
  }
  cnt = 0;
  for (int i = last_zero; i < n; i++) {
    a[i] = cnt++;
  }
  long long left_pointer, right_pointer;
  for (int i = first_zero; i < last_zero; i++) {
    if (a[i] == 0) {
      if (q.empty()) break;
      left_pointer = q.front();
      q.pop();
      if (q.empty()) break;
      right_pointer = q.front();
    } else
      a[i] = min(abs(i - left_pointer), abs(i - right_pointer));
  }
  for (int i = 0; i < n; i++) printf("%I64d ", a[i]);
  return 0;
}
