#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int A[MAXN], last = -1, N, result[MAXN];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    result[i] = MAXN;
    if (A[i] == 0) last = i;
    if (last != -1) result[i] = i - last;
  }
  last = -1;
  for (int i = N; i >= 1; --i) {
    if (A[i] == 0) last = i;
    if (last != -1) result[i] = min(result[i], last - i);
  }
  for (int i = 1; i <= N; ++i) printf("%d ", result[i]);
  puts("");
  return 0;
}
