#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int x;
  int pos1 = 0, pos2;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x == 0) {
      pos2 = i;
      for (int j = pos1 + 1; j <= pos2; j++) {
        if (pos1 != 0) {
          if (abs(pos1 - j) < abs(pos2 - j))
            cout << abs(pos1 - j) << ' ';
          else
            cout << abs(pos2 - j) << ' ';
        } else
          cout << pos2 - j << ' ';
      }
      pos1 = i;
    }
  }
  for (int i = pos2 + 1; i <= n; i++) cout << i - pos2 << ' ';
  return 0;
}
