#include <bits/stdc++.h>
using namespace std;
const long long infll = powl(2, 62) - 1;
int32_t main() {
  ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (long long i = 0; i < (long long)(n); ++i) {
    cin >> arr[i];
    if (arr[i]) arr[i] = infll;
  }
  for (long long i = 1; i <= (long long)(n - 1); ++i) {
    if (arr[i] != 0) {
      arr[i] = arr[i - 1] + 1;
    }
  }
  for (long long i = n - 2; i >= 0; i--) {
    if (arr[i] != 0) {
      arr[i] = min(arr[i], arr[i + 1] + 1);
    }
  }
  for (long long i = 0; i < (long long)(n); ++i) cout << arr[i] << ' ';
  cout << endl;
  return 0;
}
