#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653;
const long long infi = 1000000001;
const string no = "NO\n", yes = "YES\n";
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  long long n, m, i, length, d, bank, k, j, x, y, ans, q;
  string s;
  while (t--) {
    ans = 0;
    cin >> n;
    long long a[n], p[n];
    for (i = 0; i < n; i++) cin >> a[i], p[i] = 1e8;
    ans = -1;
    for (i = 0; i < n; i++) {
      if (a[i] == 0) {
        ans = 0;
      } else if (ans != -1) {
        ans++;
        p[i] = min(ans, p[i]);
      }
    }
    ans = -1;
    for (i = n - 1; i >= 0; i--) {
      if (a[i] == 0) {
        ans = 0;
        p[i] = 0;
      } else if (ans != -1) {
        ans++;
        p[i] = min(ans, p[i]);
      }
    }
    for (i = 0; i < n; i++) cout << p[i] << ' ';
  }
  return 0;
}
