Problem: 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.

Solution (in JAVA):

Solution:
import java.util.*;

public class Progress {
	
	public static boolean isProg(long[] a, int k) {
		if (k == 0) {
			return false;
		}
		if (k == 1 || k == 2) {
			return true;
		} 
		long d = a[2] - a[1];
		for (int i = 3; i <= k; i++) {
			if (a[i] - a[i-1] != d) {
				return false;
			}
		}
		return true;
	}
	
	public static void printProg(long[] a, int k) {
		for (int i = 1; i <= k; i++) {
			System.out.print(a[i]+" ");
		}
		System.out.println();
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), ind1 = 0, ind2 = 0;
		long[] m1 = new long[n + 1], m2 = new long[n + 1], m = new long[n + 1];
		boolean[] is = new boolean[n+1];
		for (int i = 1; i <= n; i++) {
			m[i] = sc.nextLong();
		}
		if (n == 4) {
			System.out.println(m[1]+" "+m[2]);
			System.out.print(m[3]+" "+m[4]);
			return;
		} else if (n == 3) {
			System.out.println(m[1]+" "+m[2]);
			System.out.print(m[3]);
			return;
		} else if (n == 2) {
			System.out.println(m[1]);
			System.out.print(m[2]);
			return;
		}
		//***
		m1 = new long[n+1];
		m2 = new long[n+1];
		int ii = 3, jj =n;
		long d1 = m[2] - m[1];
		long d2 = m[n] - m[n-1];
		while (m[ii] - m[ii-1] == d1 && ii<n) {
			ii++;
		}
		while (m[jj] - m[jj-1] == d2 && jj>1) {
			jj--;
		}
		for (int k = ii-1; k<=jj - 1 && ii <= jj; k++) {
			ind1++;
			m1[ind1] = m[k];
		}
		for (int k = 1; k< ii-1 && ii <= jj; k++) {
			ind2++;
			m2[ind2] = m[k];
		}
		for (int k = jj; k<=n && ii <= jj; k++) {
			ind2++;
			m2[ind2] = m[k];
		}
		if (isProg(m1,ind1) && isProg(m2,ind2)) {
			printProg(m1, ind1);
			printProg(m2, ind2);
			return;
		}
		//***
		m1 = new long[n+1];
		m2 = new long[n+1];
		ind1 = 2;
		ind2 = 0;
		boolean ff = true;
		d1 = m[2] - m[1];
		m1[1] = m[1];
		m1[2] = m[2];
		d2 = 0;
		for (int j = 2 + 1; j <= n && ff; j++) {
			if (m[j] == m1[ind1] + d1 && m[j] == m2[ind2] + d2 && ind2 != 0 && ind2!= 1 && j!=n) {
				if (m[j + 1] == m[j] + d1) {
					ind1++;
					m1[ind1] = m[j];
					continue;
				}
				if (m[j + 1] == m[j] + d2) {
					ind2++;
					m2[ind2] = m[j];
					if (ind2 == 2) {
						d2 = m2[2] - m2[1];
					}
					continue;
				}
			}
			if (m[j] == m1[ind1] + d1) {
				ind1++;
				m1[ind1] = m[j];
				continue;
			}

			if (ind2 == 0 || ind2 == 1 || m[j] == m2[ind2] + d2) {
				ind2++;
				m2[ind2] = m[j];
				if (ind2 == 2) {
					d2 = m2[2] - m2[1];
				}
				continue;
			}
			ff = false;
		}
		if (ff) {
			if (ind2 == 0) {
				for (int i = 1; i <= ind1 - 1; i++) {
					System.out.print(m1[i]+" ");
				}
				System.out.println();
				System.out.print(m1[ind1]+" ");
				return;
			}
			printProg(m1, ind1);
			printProg(m2, ind2);
			return;
		}
		
		m1 = new long[n+1];
		m2 = new long[n+1];
		ind1 = 2;
		ind2 = 0;
		
		d1 = m[3] - m[2];
		m1[1] = m[2];
		m1[2] = m[3];
		d2 = 0;
		ff = true;
		ind2++;
		m2[ind2] = m[1];
		for (int j = 3 + 1; j <= n && ff; j++) {
			if (m[j] == m1[ind1] + d1 &&  m[j] == m2[ind2] + d2  && ind2 != 1 && j!=n) {
				if (m[j + 1] == m[j] + d1) {
					ind1++;
					m1[ind1] = m[j];
					continue;
				} 
				if (m[j + 1] == m[j] + d2 ) {
					ind2++;
					m2[ind2] = m[j];
					if (ind2 == 2) {
						d2 = m2[2] - m2[1];
					}
					continue;
				}
			}
			if (m[j] == m1[ind1] + d1) {
				ind1++;
				m1[ind1] = m[j];
				continue;
			}
			if (ind2 == 0 || ind2 == 1 ||m[j] == m2[ind2] + d2) {
				ind2++;
				m2[ind2] = m[j];
				if (ind2 == 2) {
					d2 = m2[2] - m2[1];
				}
				continue;
			}
			ff = false;
		}
		if (ff) {
			if (ind2 == 0) {
				for (int i = 1; i <= ind1 - 1; i++) {
					System.out.print(m1[i]+" ");
				}
				System.out.println();
				System.out.print(m1[ind1]+" ");
				return;
			}
			printProg(m1, ind1);
			printProg(m2, ind2);
			return;
		}
		m1 = new long[n+1];
		m2 = new long[n+1];
		ind1 = 2;
		ind2 = 0;
		
		d1 = m[3] - m[1];
		m1[1] = m[1];
		m1[2] = m[3];
		d2 =0;
		ff = true;
		ind2++;
		m2[ind2] = m[2];
		for (int j =3 + 1; j <= n && ff; j++) {
			if (m[j] == m1[ind1] + d1 && m[j] == m2[ind2] + d2 && ind2 != 1 && j!=n) {
				if (m[j + 1] == m[j] + d1) {
					ind1++;
					m1[ind1] = m[j];
					continue;
				}
				if (m[j + 1] == m[j] + d2 ) {
					ind2++;
					m2[ind2] = m[j];
					if (ind2 == 2) {
						d2 = m2[2] - m2[1];
					}
					continue;
				}
			}
			if (m[j] == m1[ind1] + d1) {
				ind1++;
				m1[ind1] = m[j];
				continue;
			}
			if (ind2 == 0 || ind2 == 1 ||m[j] == m2[ind2] + d2) {
				ind2++;
				m2[ind2] = m[j];
				if (ind2 == 2) {
					d2 = m2[2] - m2[1];
				}
				continue;
			}
			ff = false;
		}
		if (ff) {
			if (ind2 == 0) {
				for (int i = 1; i <= ind1 - 1; i++) {
					System.out.print(m1[i]+" ");
				}
				System.out.println();
				System.out.print(m1[ind1]+" ");
				return;
			}
			printProg(m1, ind1);
			printProg(m2, ind2);
			return;
		}
		System.out.print("No solution");
	}
}