You are given the array of integer numbers a0, a1, ..., an - 1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — length of the array a. The second line contains integer elements of the array separated by single spaces ( - 109 ≤ ai ≤ 109).

Output

Print the sequence d0, d1, ..., dn - 1, where di is the difference of indices between i and nearest j such that aj = 0. It is possible that i = j.

Examples

Input

9
2 1 0 3 0 0 3 2 4


Output

2 1 0 1 0 0 1 2 3 

Input

5
0 1 2 3 4


Output

0 1 2 3 4 

Input

7
5 6 0 1 -2 3 4


Output

2 1 0 1 2 3 4 
import java.util.*;
import java.io.*;


public class Main {

	public static final boolean fileIO = false;
	public static final int INF = 0x7FFFFFFF;
	public static final int EPS = (int)1e9 + 7;

	public static void main(String args[]) throws IOException {
		InputStream is = null;
		OutputStream os = null;
		if (fileIO) {
			is = new FileInputStream("input.txt");
			os = new FileOutputStream("output.txt");
		} else {
			is = System.in;
			os = System.out;
		}
		InputReader in = new InputReader(is);
		PrintWriter out = new PrintWriter(os);
		//
		new Task_B().solve(in, out);
		//
		out.close();

	}

	static class Task_B {

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			Integer a[] = in.nextIntArray(n);
			//
			Integer d[] = new Integer[n];
			Arrays.fill(d, INF);
			Queue< Integer > q = new LinkedList<>();
			for (int i = 0; i < a.length; i++) {
				if (a[i] == 0) {
					q.add(i);
				}
			}
			//
			for (int i = 0; i < n; i++) {
				int f = INF;
				if (!q.isEmpty()) f = q.poll();
				while (i <= f && i < n) {
					if (i > 0) d[i] = d[i - 1] + 1;
					d[i] = Math.min(d[i], f - i);
					i++;
				}
				i--;
			}
			//
			for (int v : d) out.print(v + " ");
			out.println();
		}
	}


	static class InputReader {

		private StringTokenizer tokenizer;
		private BufferedReader reader;

		public InputReader(InputStream is) {
			tokenizer = null;
			reader = new BufferedReader(new InputStreamReader(is), 32768);
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = reader.readLine();
					tokenizer = new StringTokenizer(line); // ' ' -> delimiter
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public Integer nextInt() { return Integer.parseInt(next()); }
		public Integer[] nextIntArray(int n) {
			int i = 0;
			Integer ret[] = new Integer[n];
			while (i < n) ret[i++] = nextInt();
			return ret;
		}

		public Long nextLong() { return Long.parseLong(next()); }
		public Long[] nextLongArray(int n) {
			int i = 0;
			Long ret[] = new Long[n];
			while (i < n) ret[i++] = nextLong();
			return ret;
		}
	}

}