#include <bits/stdc++.h>
const int inf = 2e5 + 10;
const long long mod = 998244353;
const int MOST_LARGE = 0x3f3f3f3f;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[] = {1, 1, 0, -1, -1, -1, 0, 1};
int bx[] = {0, 1, 0, -1};
int by[] = {-1, 0, 1, 0};
using namespace std;
const int SIZE = 100010;
int a[inf];
int b[inf];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(b, MOST_LARGE, sizeof(b));
  int tmp = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      b[i] = 0;
      tmp = i;
    } else if (tmp != -1)
      b[i] = i - tmp;
  }
  tmp = -1;
  for (int i = n; i >= 1; i--) {
    if (a[i] == 0)
      tmp = i;
    else if (tmp != -1)
      b[i] = min(b[i], tmp - i);
  }
  for (int i = 1; i <= n; i++)
    if (i == 1)
      printf("%d", b[i]);
    else
      printf(" %d", b[i]);
}
