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:
def sol(prog1, rest, nums):
  start = len(prog1) + len(rest)
  diff1 = prog1[1] - prog1[0]

  prog2 = []

  for x in xrange(start, len(nums)):
    val = nums[x]
    next1 = prog1[-1] + diff1
    if val == next1:
      prog1.append(val)
    else:
      rest.append(val)

  if len(rest) <= 2:
    return prog1, rest

  #print "ASD", prog1, rest
  prog1_set = set(prog1)

  diff2 = rest[1] - rest[0]
  prog2 = [rest[0], rest[1]]
  for x in xrange(2, len(rest)):
    next2 = prog2[-1] + diff2
    val = rest[x]

    #print next2, val
    while next2 != val:
      if next2 in prog1_set:
        prog1_set.remove(next2)
      else:
        return False
      prog2.append(next2)
      next2 = prog2[-1] + diff2

    prog2.append(val)

  prog1 = list(sorted(prog1_set))
  diff1 = abs(diff1)
  prog2 = list(sorted(prog2))
  diff2 = abs(diff2)

  for x in xrange(1, len(prog1)):
    if prog1[x] - prog1[x-1] != diff1:
      return False
  for x in xrange(1, len(prog2)):
    if prog2[x] - prog2[x-1] != diff2:
      return False

  return prog1, prog2

def d1(nums):
  if len(nums) == 2:
    return [nums[0]], [nums[1]]

  a, b, c = nums[0], nums[1], nums[2]
  # print a, b, c, nums[3:]
  # a, b
  res = sol([a, b], [], nums)
  if res != False:
    return res

  # a, c
  res = sol([a, c], [b], nums)
  if res != False:
    return res

  # b, c
  res = sol([b, c], [a], nums)
  if res != False:
    return res

  return False

def d(nums):
  res = d1(nums)

  if res is False:
    res = d1(list(reversed(nums)))

  if res is False:
    return "No solution"

  if len(res[0]) == 0:
    res = [res[1][0]], res[1][1:]
  if len(res[1]) == 0:
    res = res[0][1:], [res[0][0]]

  if len(res[0]) >= 2:
    if nums.index(res[0][0]) > nums.index(res[0][1]):
      res = list(reversed(res[0])), res[1]
  if len(res[1]) >= 2:
    if nums.index(res[1][0]) > nums.index(res[1][1]):
      res = res[0], list(reversed(res[1]))

  return res

'''
vals = [4, 1, 2, 7, 3, 10]
answer = d(vals)
print vals
print answer
vals = [1, 2, 3, -2, -7]
answer = d(vals)
print vals
print answer
vals = [-10, -5, 0, 1, 2, 3, 4, 5, 6,]
answer = d(vals)
print vals
print answer
vals = [0, 3, 4, 5, 6, 12, 18]
answer = d(vals)
print vals
print answer
'''

unused = raw_input()
answer = d([int(x) for x in raw_input().split(" ")])

if type(answer) == str:
  print answer
else:
  print " ".join(str(_) for _ in answer[0])
  print " ".join(str(_) for _ in answer[1])