#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, tmp = 0, dau = 0, sau = 0;
  cin >> n;
  int so[n];
  vector<int> khong;
  for (i = 0; i < n; i++) {
    cin >> so[i];
    if (so[i] == 0) khong.push_back(i);
  }
  for (i = 0; i < n; i++) {
    while (khong[dau] < i && dau < khong.size() - 1 && khong[dau + 1] < i)
      dau++;
    sau = dau + 1;
    if (sau > khong.size() - 1) sau = khong.size() - 1;
    if (dau > khong.size() - 1) dau = khong.size() - 1;
    if (abs(i - khong[dau]) < abs(i - khong[sau]))
      cout << abs(i - khong[dau]) << " ";
    else
      cout << abs(i - khong[sau]) << " ";
  }
}
