Problem: Alexey recently held a programming contest for students from Berland. n students participated in a contest, i-th of them solved ai problems. Now he wants to award some contestants. Alexey can award the students with diplomas of three different degrees. Each student either will receive one diploma of some degree, or won't receive any diplomas at all. Let cntx be the number of students that are awarded with diplomas of degree x (1 ≤ x ≤ 3). The following conditions must hold:

  * For each x (1 ≤ x ≤ 3) cntx > 0; 
  * For any two degrees x and y cntx ≤ 2·cnty. 



Of course, there are a lot of ways to distribute the diplomas. Let bi be the degree of diploma i-th student will receive (or  - 1 if i-th student won't receive any diplomas). Also for any x such that 1 ≤ x ≤ 3 let cx be the maximum number of problems solved by a student that receives a diploma of degree x, and dx be the minimum number of problems solved by a student that receives a diploma of degree x. Alexey wants to distribute the diplomas in such a way that:

  1. If student i solved more problems than student j, then he has to be awarded not worse than student j (it's impossible that student j receives a diploma and i doesn't receive any, and also it's impossible that both of them receive a diploma, but bj < bi); 
  2. d1 - c2 is maximum possible; 
  3. Among all ways that maximize the previous expression, d2 - c3 is maximum possible; 
  4. Among all ways that correspond to the two previous conditions, d3 - c - 1 is maximum possible, where c - 1 is the maximum number of problems solved by a student that doesn't receive any diploma (or 0 if each student is awarded with some diploma). 



Help Alexey to find a way to award the contestants!

Input

The first line contains one integer number n (3 ≤ n ≤ 3000).

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 5000).

Output

Output n numbers. i-th number must be equal to the degree of diploma i-th contestant will receive (or  - 1 if he doesn't receive any diploma).

If there are multiple optimal solutions, print any of them. It is guaranteed that the answer always exists.

Examples

Input

4
1 2 3 4


Output

3 3 2 1 


Input

6
1 4 3 1 1 2


Output

-1 1 2 -1 -1 3 

Solution (in JAVA):

Solution:

import java.io.*;
import java.util.*;

public class A {

	static final int INF = (int)1e9;
	static Pair[] a;
	static SegmentTree st;

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		a = new Pair[n];
		for(int i = 0; i < n; ++i)
			a[i] = new Pair(sc.nextInt(), i);
		Arrays.sort(a);
		int[] d = new int[n];
		for(int i = 0; i + 1 < n; ++i)
			d[i] = a[i].val - a[i + 1].val;
                d[n - 1] = a[n - 1].val;
		st = new SegmentTree(d);
		int[] ans = {-INF, -INF, -INF}, cnt = null;
		for(int i = 1; i + 1 < n; ++i)
			for(int j = i; j + 1 < n; ++j)
			{
				int[][] cur = solve(i, j, n);
				if(cur != null && better(cur[0], ans))
				{
					ans = cur[0];
					cnt = cur[1];
				}
			}
		int[] res = new int[n];
		for(int idx = 0; idx < n; ++idx)
		{
			Pair p = a[idx];
			if(idx < cnt[0])
				res[p.idx] = 1;
			else if(idx < cnt[1])
				res[p.idx] = 2;
			else if(idx < cnt[2])
				res[p.idx] = 3;
			else
				res[p.idx] = -1;
		}
		StringBuilder sb = new StringBuilder();
		for(int x: res)
			sb.append(x + " ");
		out.println(sb);
		out.close();
	}

	static boolean badCount(int x, int y) { return x > y * 2 || x * 2 < y; }

	static int[][] solve(int l, int r, int n)
	{
		int cntX = l, cntY = r - l + 1;
		if(badCount(cntX, cntY))
			return null;
		int zMin = (Math.max(cntX, cntY) + 1) / 2, zMax = Math.min(Math.min(cntX, cntY) * 2, n - r - 1);
		if(zMin > zMax)
			return null;
		Pair qAns = st.query(r + zMin, r + zMax); 
		int cntZ = qAns.idx - 1 - r;
		int[] retCnt = {cntX, cntX + cntY, cntX + cntY + cntZ};
		int d1 = a[cntX - 1].val - a[cntX].val;
		int d2 = a[retCnt[1] - 1].val - a[retCnt[1]].val;
		int d3 = a[retCnt[2] - 1].val - (retCnt[2] == n ? 0 : a[retCnt[2]].val);
		int[] retDiff = {d1, d2, d3};
		return new int[][] {retDiff, retCnt};
	}

	static boolean better(int[] x, int[] y)
	{
		for(int i = 0; i < 3; ++i)
			if(x[i] > y[i])
				return true;
			else if(x[i] < y[i])
				return false;
		return false;
	}

	static class Pair implements Comparable<Pair>
	{
		int val, idx;

		Pair(int a, int b) { val = a; idx = b; }

		public int compareTo(Pair p) { return p.val - val;}
	}

	static class SegmentTree {

		int N;
		int[] arr;
		Pair[] tree;

		SegmentTree(int[] a)
		{
			arr = a;
			N = 1; while(N < a.length) N <<= 1;
			tree = new Pair[N << 1];
			build(1, 1, N);
		}

		void build(int node, int b, int e)
		{
			if (b == e)
				tree[node] = new Pair(b <= arr.length ? arr[b - 1] : -1, b);
			else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				tree[node] = combine(tree[node << 1], tree[node << 1 | 1]);
			}
		}

		Pair combine(Pair x, Pair y)
		{
			if(x.val >= y.val)
				return x;
			return y;
		}

		Pair query(int i, int j) {
			return query(1, 1, N, i + 1, j + 1);
		}

		Pair query(int node, int b, int e, int i, int j)
		{
			if (i > e || j < b)
				return new Pair(-1, 0);
			if (b >= i && e <= j)
				return tree[node];
			int mid = b + e >> 1;
			Pair q1 = query(node << 1, b, mid, i, j);
			Pair q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return combine(q1, q2);

		}
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException {	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}
	}
}