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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.TreeSet;

public class B {
	
	static int INF = 10000000;
	
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = in.nextInt();
		int[] a = new int[n];
		TreeSet<Integer> t = new TreeSet<>();
		t.add(-INF);
		t.add(INF);
		for(int i=0; i<n; ++i) {
			a[i] = in.nextInt();
			if(a[i] == 0) {
				t.add(i);
			}
		}
		
//		int first = t.tailSet(-INF + 1).first();
//		int last = t.headSet(INF - 1).last();
		for(int i=0; i<n; ++i) {
			if(a[i] == 0)
				System.out.print(0);
//			else if(i < first)
//				System.out.print(first - i);
//			else if(i > last)
//				System.out.print(i - last);
			else
				System.out.print( Math.min(i - t.floor(i), t.ceiling(i) - i) );
			System.out.print( " " );
		}
		
//		
//		
//		
//		
//		
//		
//		int[] a = new int[n];
//		int[] dis = new int[n];
//		
//		for(int i=0; i<n; ++i) {
//			a[i] = in.nextInt();
//			dis[i] = Integer.MAX_VALUE;
//		}
//		
//		int pos = -1;
//		for(int i=0; i<n; ++i) {
//			if(a[i] == 0) {
//				pos = i;
//			}
//			if(pos != -1) {
//				dis[i] = i - pos;
//			}
//		}
//		
//		pos = -1;
//		for(int i=n-1; i>=0; --i) {
//			if(a[i] == 0) {
//				pos = i;
//			}
//			if(pos != -1) {
//				dis[i] = Math.min(dis[i], pos - i);
//			}
//		}
//		
//		for(int x : dis)
//			out.print(x + " ");
		
		out.close();
	}
	
	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}
}