#include <bits/stdc++.h>
const int OO = (int)2e9;
const long long INF = (long long)4e18;
const double EPS = (double)1e-12;
using namespace std;
int n, ret;
int dat[200005];
int main() {
  scanf("%d", &n);
  dat[0] = dat[n + 1] = 200000;
  for (int i = 1; i <= n; i += 1) scanf("%d", dat + i);
  for (int i = 1; i <= n; i += 1)
    if (dat[i] != 0) dat[i] = dat[i - 1] + 1;
  for (int i = n; i >= 1; i -= 1) dat[i] = min(dat[i], dat[i + 1] + 1);
  for (int i = 1; i <= n; i += 1) printf("%d ", dat[i]);
  return 0;
}
