#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int m, n, k;
int ans;
long long a[N];
int mp[1000][1000];
int b[N];
vector<int> in;
bool check(int x, int i) {
  int bg = max(1, i - x);
  int ed = min(n, i + x);
  for (int j = bg; j <= ed; j++) {
    if (a[j] == 0) return true;
  }
  return false;
}
int main() {
  int T;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] == 0) in.push_back(i);
  }
  in.push_back(0x3f3f3f3f);
  for (int i = 1; i <= n; i++) {
    int id = lower_bound(in.begin(), in.end(), i) - in.begin();
    b[i] = min(abs(in[id - 1] - i), abs(in[id] - i));
  }
  for (int i = 1; i < n; i++) printf("%d ", b[i]);
  printf("%d\n", b[n]);
  return 0;
}
