#include <bits/stdc++.h>
using namespace std;
int n, a[1234567], ans[1234567];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int in = 0;
  for (int i = 0; i < n; i++)
    if (!a[i]) {
      in = i;
      break;
    }
  for (int i = 0; i <= in; i++) ans[i] = in - i;
  for (int i = in + 1; i < n; i++) {
    if (!a[i]) in = i;
    ans[i] = abs(i - in);
  }
  for (int i = n - 1; i >= 0; i--)
    if (!a[i]) {
      in = i;
      break;
    }
  for (int i = n - 1; i >= 0; i--) {
    if (!a[i]) in = i;
    ans[i] = min(ans[i], abs(i - in));
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
