#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
void right() {
  cout << "Yes\n";
  exit(0);
}
void fail() {
  cout << -1;
  exit(0);
}
vector<vector<int>> g;
int c = 0;
map<int, int> vis;
void dfs(int v) {
  c++;
  vis[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    if (!vis[g[v][i]]) dfs(g[v][i]);
  }
}
int zero[200005];
int a[200005];
int main() {
  int n;
  cin >> n;
  int m;
  int front = -1e9;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) front = i;
    zero[i] = i - front;
  }
  front = 1e9;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) front = i;
    zero[i] = min(zero[i], front - i);
  }
  for (int i = 0; i < n; i++) cout << zero[i] << " ";
}
