#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const long long LINF = 1000000000000000000;
const long long MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void add(T& a, T b) {
  a = ((a + b) % MOD + MOD) % MOD;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), ans(n, INF);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int pre = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) pre = i;
    if (pre != -1) chmin(ans[i], i - pre);
  }
  pre = -1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) pre = i;
    if (pre != -1) chmin(ans[i], pre - i);
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
