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 PYTHON):

Solution:
import sys
# infile = open(sys.argv[1], 'r')
infile = sys.stdin
def input():
	return infile.readline().rstrip()

n = int(input())
a = map(int, input().split())

def isAP(arr):
	n = len(arr)
	if n == 0:
		return False
	if n == 1:
		return True
	d = arr[1] - arr[0]
	for i in xrange(2, n):
		if arr[i] - arr[i-1] != d:
			return False
	return True

def test(a, a10, a20):
	n = len(a)
	a1 = a10[:]
	a2 = a20[:]
	# assume len(a1) = 2
	d1 = a1[1] - a1[0]
	i = 0
	while i < n:
		can1 = False
		can2 = False
		if a[i] - a1[-1] == d1:
			can1 = True
		if len(a2) < 2 or a[i] - a2[-1] == d2:
			can2 = True
		if can1 and can2:
			if len(a2) == 0:
				can2 = False
			elif len(a2) == 1:
				# if add to a2, a1 must die
				# if add to a1, a2 can live

				# try add to a1
				for j in xrange(i, n):
					if a[j] - a1[-1] ==  d1:
						a1.append(a[j])
					else:
						break
				else:
					return (a1, a2)
				can1 = False
				temp_a = a[j:]
				if isAP(a2+[a1[-1]]+temp_a):
					a2 = a2 + [a1.pop()] + temp_a
					return (a1, a2)
				# let can2 be true
				i = j
			else:
				# one in a1, a2 must die
				# len(a2) >= 2
				# try add to a1, then all following should be added to a1. That means a2 is "dead"
				if isAP(a1 + a[i:]):
					a1 = a1 + a[i:]
					return (a1, a2)
				# not success, try add to a2. Let a1 die
				if isAP(a2 + a[i:]):
					a2 = a2 + a[i:]
					return (a1, a2)
				return False
		if can1:
			a1.append(a[i])
		elif can2:
			a2.append(a[i])
			if len(a2) == 2:
				d2 = a2[-1] - a2[-2]
		else:
			return False
		# print a1
		# print a2
		i += 1

	return (a1, a2)

if isAP(a):
	print a[0]
	print ' '.join([str(i) for i in a[1:]])
else:
	# a candidate is (a_pos, a1, a2)
	candies = ((2, [a[0], a[1]], []),
			(3, [a[0], a[2]], [a[1]]),
			(3, [a[1], a[2]], [a[0]]))
	succ = False
	for a_pos, a1, a2 in candies:
		# print "Candidate------------------------------"
		res = test(a[a_pos:], a1, a2)
		if res:
			a1, a2 = res
			print ' '.join([str(i) for i in a1])
			print ' '.join([str(i) for i in a2])
			break
	else:
		print 'No solution'