#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535;
long long n, m;
const int mx = 69;
char grid[mx][mx];
long long blocked[mx][mx];
long long vis[mx][mx];
void FAST() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long power(long long a, long long b) {
  long long res = 1;
  for (int i = 1; i <= b; ++i) res *= a;
  return res;
}
int main() {
  FAST();
  long long n;
  cin >> n;
  vector<long long> v(n);
  long long lt = -1000000;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 0) lt = i;
    v[i] = i - lt;
  }
  reverse(v.begin(), v.end());
  lt = -1000000;
  for (long long i = 0; i < n; i++) {
    if (v[i] == 0) lt = i;
    v[i] = min(v[i], i - lt);
  }
  reverse(v.begin(), v.end());
  for (long long i = 0; i < n; i++) cout << v[i] << ' ';
}
