#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn];
int vis[maxn];
int dis[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int i, j, k, m, n;
  queue<pair<int, int> > q;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] == 0) {
      q.push(make_pair(i, 0));
      vis[i] = 1;
    }
  }
  while (!q.empty()) {
    pair<int, int> v = q.front();
    q.pop();
    v.second++;
    if (!vis[v.first + 1] && v.first + 1 <= n) {
      vis[v.first + 1] = 1;
      dis[v.first + 1] = v.second;
      q.push(make_pair(v.first + 1, v.second));
    }
    if (!vis[v.first - 1] && v.first - 1 >= 1) {
      vis[v.first - 1] = 1;
      dis[v.first - 1] = v.second;
      q.push(make_pair(v.first - 1, v.second));
    }
  }
  for (int i = 1; i <= n; ++i) cout << dis[i] << " ";
  return 0;
}
