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.io.*;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class DistancesToZero {

	public static FastScanner in = new FastScanner(System.in);

	public static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public FastScanner(InputStream i) {
			reader = new BufferedReader(new InputStreamReader(i));
			tokenizer = new StringTokenizer("");
		}

		public String next() throws IOException {
			while (!tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(reader.readLine());
			return tokenizer.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public void close() throws IOException {
			reader.close();
		}

	}

	public static interface OnRead {
		public boolean use(int i);
	}

	public static OnRead doNothing = new OnRead() {
		@Override
		public boolean use(int i) {
			return false;
		}
	};

	public static void intNvalues(int n) throws IOException {
		intNvalues(n, doNothing);
	}

	public static void intNvalues(int n, OnRead r) throws IOException {
		intN = new int[n];
		boolean stopUse = false;
		for (int i = 0; i < n; i++) {
			intN[i] = in.nextInt();
			stopUse = stopUse || r.use(i);
		}
	}

	public static int[] intN;

	// variables

	public static int n;
	public static LinkedList<Integer> nodes = new LinkedList<Integer>();
	public static LinkedList<Integer> distanceToNode = new LinkedList<Integer>();

	// onReads

	public static OnRead getNodes = new OnRead() {
		@Override
		public boolean use(int i) {
			if (intN[i] == 0) {
				nodes.add(i);
				distanceToNode.add(0);
			}
			return false;
		}
	};

	public static void main(String[] args) {
		try {
			// readValues
			n = in.nextInt();
			intNvalues(n, getNodes);
			Arrays.fill(intN, Integer.MAX_VALUE);
			// useFunctions
			setDistance();
			// printResult
			for (int d : intN)
				System.out.print(d + " ");
			in.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// functions

	public static void setDistance() {
		while (!nodes.isEmpty())
			setDistance(nodes.poll(), distanceToNode.poll());
	}

	private static void setDistance(int index, int distance) {
		if (intN[index] > distance) {
			intN[index] = distance;
			if (index > 0) {
				nodes.add(index - 1);
				distanceToNode.add(distance + 1);
			}
			if (index < n - 1) {
				nodes.add(index + 1);
				distanceToNode.add(distance + 1);
			}
		}
	}
}