An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progression. The definition implies that any sequences whose length equals 1 or 2 are arithmetic and all sequences whose length equals 0 are non-arithmetic.

You are given a sequence of different integers a1, a2, ..., an. You should either split it into two arithmetic progressions or find out that the operation is impossible to perform. Splitting assigns each member of the given sequence to one of two progressions, but the relative order of numbers does not change. Splitting is an inverse operation to merging.

Input

The first line contains a positive integer n (2 ≤ n ≤ 30000), n is the length of the given sequence. The second line contains elements of the given sequence a1, a2, ..., an ( - 108 ≤ ai ≤ 108). The elements of the progression are different integers.

Output

Print the required arithmetic progressions, one per line. The progressions can be positioned in any order. Each progression should contain at least one number. If there's no solution, then print "No solution" (without the quotes)in the only line of the input file. If there are several solutions, print any of them.

Examples

Input

6
4 1 2 7 3 10


Output

1 2 3 
4 7 10 


Input

5
1 2 3 -2 -7


Output

1 2 3 
-2 -7 

Note

In the second sample another solution is also possible (number three can be assigned to the second progression): 1, 2 and 3, -2, -7.
import java.io.*;
import java.lang.Math;
import java.util.Scanner;

public class D
{
	public static Scanner in;
	public static PrintStream out;
	
	static int[] a;
	
	private static class Seq
	{
		int first, last, d, count;
		boolean has_last, has_d;
		
		public void Seq()
		{
			has_last = false;
			has_d = false;
			count = 0;
		}
		
		public boolean test(int x)
		{
			if (!has_d)
			{
				return true;
			}
			
			return last+d == x;
		}
		
		public boolean test2(int x, int y)
		{
			if (!has_last)
			{
				return true;
			}
			
			if (!has_d)
			{
				return x-last == y-x;
			}
			
			return x+d == y;
		}
		
		public void set_next(int x)
		{
			if (has_last && !has_d)
			{
				d = x - last;
				has_d = true;
			}
			
			if (!has_last)
			{
				first = x;
				has_last = true;
			}
			
			last = x;
			
			count++;
		}
		
		public Seq copy()
		{
			Seq s = new Seq();
			s.has_d = has_d;
			s.has_last = has_last;
			s.d = d;
			s.last = last;
			s.first = first;
			s.count = count;
			return s;
		}
		
		public void show()
		{
			out.print(first);
			int x = first;
			for (int i=1; i<count; i++)
			{
				out.print(" ");
				x+= d;
				out.print(x);				
			}
			if (count==0)
			{
					out.print("*");
			}
			out.println();
			
			
		}
	}
	
	private static class Hypoth
	{
		Seq a, b;
		boolean active;
		
		public Hypoth()
		{
			a = new Seq();
			b = new Seq();
			active = true;
		}
		
		public Hypoth copy()
		{
			Hypoth h = new Hypoth();
			h.a = a.copy();
			h.b = b.copy();
			h.active = active;
			return h;
		}
	}
	
	public static void test()
	{
		int k,j,i,n = in.nextInt();
		a = new int[n];
		
		Seq s;
		
		for (i=0; i<n; i++)
		{
			a[i] = in.nextInt();
		}
		
		Hypoth[] h_list = new Hypoth[30005];
		Hypoth h, h2;
		int x,h_count = 0;
		
		h_list[h_count++] = new Hypoth();
		h_list[0].a.set_next(a[0]);
		
		boolean t1, t2, tn1, tn2;
		
		for (i=1; i<n; i++)
		{
			x = a[i];
			k = h_count;
			/*
			out.print("{{{{  ");
			out.print(a[i]);
			
			out.println("   }}}} :");
			*/
			for (j=0; j<k; j++)
			{
				h  = h_list[j];
				
				if (h.b.has_d && !h.a.has_d)
				{
					s = h.a;
					h.a = h.b;
					h.b = s;
				}
				/*
				out.println(">>>");
				
				h.a.show();
				h.b.show();
				*/
				t1 = h.a.test(x);
				t2 = h.b.test(x);
				/*
				out.print(t1);
				out.print("/");
				out.print(t2);
				out.println();
				*/
				if (t1 && t2)
				{
					if (i+1 == n)
					{
						h.b.set_next(x);
					}
					else
					{
						if (h.b.has_d)
						{
							if (a[i+1]==x)
							{
								h.a.set_next(x);
							}
							else
							{
								tn1 = h.a.test2(x, a[i+1]);
								tn2 = h.b.test2(x, a[i+1]);
								
								if (tn1)
								{
									h.a.set_next(x);
								}
								else if (tn2)
								{
									h.b.set_next(x);
								}
								else
								{
									h.active = false;
								}
							}
						}
						else
						{
							//out.println("kuku");
						
							if (! ((h.a.count>2)&&(h.b.count==0)&&(h.a.d == a[i+1]-x)))
							{
								h2 = h.copy();
								h2.b.set_next(x);
								h_list[h_count++] = h2;
							}
							
							h.a.set_next(x);
							
						}
					}
				}
				else if (t1)
				{
					h.a.set_next(x);
				}
				else if (t2)
				{
					h.b.set_next(x);
				}
				else
				{
					h.active = false;
				}				
			}
			
			//out.println("********** Hypoth:");
			
			k = 0;
			for (j=0; j<h_count;j++)
			{
				if (h_list[j].active)
				{
					h_list[k++] = h_list[j];
				}
			}
			
			h_count = k;
		}
		
		if (h_count > 0)
		{
			h_list[0].a.show();
			h_list[0].b.show();
		}
		else
		{
			out.println("No solution");
		}
	}
       
	public static void main(String args[])
	{
		try
		{
			//in = new Scanner(new File("in.txt"));
			//out = new PrintStream(new File("out.txt"));
			in = new Scanner(System.in);
			out = System.out;
		}
		catch (Exception e)
		{
			return;
		}
	   
	   
		test();
	}
}

