#include <bits/stdc++.h>
#pragma comment(linker, ”/ STACK : 38777216“
using namespace std;
const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
int n, a[N];
set<int> q;
set<int>::iterator it;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) q.insert(i);
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0)
      printf("0 ");
    else {
      int answ = inf;
      q.insert(i);
      it = q.find(i);
      ++it;
      if (it != q.end()) answ = min(answ, *it - i);
      --it;
      if (it != q.begin()) {
        --it;
        answ = min(answ, i - *it);
        ++it;
      }
      q.erase(i);
      printf("%d ", answ);
    }
  }
  cout << endl;
  return 0;
}
