#include <bits/stdc++.h>
using namespace std;
int n, tmp, ans[200002];
vector<int> a;
void bfs(int const u) {
  queue<pair<int, int> > q;
  q.push(pair<int, int>(u, 0));
  while (!q.empty()) {
    int tmp = q.front().first;
    int cur = q.front().second;
    q.pop();
    if (tmp - 1 > 0 && ans[tmp - 1] > cur + 1)
      q.push(pair<int, int>(tmp - 1, ans[tmp - 1] = cur + 1));
    if (tmp + 1 <= n && ans[tmp + 1] > cur + 1)
      q.push(pair<int, int>(tmp + 1, ans[tmp + 1] = cur + 1));
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &tmp);
    if (!tmp)
      a.push_back(i);
    else
      ans[i] = 1000000009;
  }
  for (int i = 0; i < (int)a.size(); ++i) bfs(a[i]);
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  puts("");
  return 0;
}
