#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const long long INFF = 1e18;
const int INF = 1e9;
const int mod = 1e9 + 7;
const int MAX = 2e5 + 7;
int a[MAX];
int ans[MAX];
int main(void) {
  int n;
  scanf("%d", &n);
  ;
  for (int i = (1); i < (n + 1); ++i) scanf("%d", a + i);
  int p = -INF;
  for (int i = (1); i < (n + 1); ++i) {
    if (!a[i]) p = i;
    ans[i] = i - p;
  }
  p = INF;
  for (int i = n; i >= 1; --i) {
    if (!a[i]) p = i;
    ans[i] = min(ans[i], p - i);
  }
  for (int i = (1); i < (n + 1); ++i) printf("%d%c", ans[i], " \n"[i == n]);
  return 0;
}
