#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int arr[n];
  long long int i;
  for (i = 0; i < n; i++) cin >> arr[i];
  long long int right[n];
  long long int left[n];
  for (i = 0; i < n; i++) left[i] = -1, right[i] = -1;
  for (i = 0; i < n; i++) {
    if (arr[i] == 0)
      left[i] = i;
    else
      left[i] = (i - 1 >= 0) ? left[i - 1] : -1;
  }
  for (i = n - 1; i >= 0; i--) {
    if (arr[i] == 0)
      right[i] = i;
    else
      right[i] = (i + 1 < n) ? right[i + 1] : -1;
  }
  for (i = 0; i < n; i++) {
    long long int ans = n + 1;
    if (left[i] != -1) ans = min(ans, i - left[i]);
    if (right[i] != -1) ans = min(ans, right[i] - i);
    cout << ans << " ";
  }
}
