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

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 30000;
const int unknown = (int)1e9 + 28;
bool marked[2][N];
int a[N], n, finish[2];
void output() {
  for (int j = 0; j < 2; ++j) {
    for (int i = 0; i < n; ++i)
      if (marked[j][i] && (i < finish[j])) printf("%d ", a[i]);
    printf("\n");
  }
  exit(0);
}
void mark(int begin, int delta, bool* marked) {
  int current = begin;
  for (int i = 0; i < n; ++i)
    if (a[i] == current) marked[i] = true, current += delta;
}
void build(int begin1, int delta1, int begin2, int delta2) {
  memset(marked, 0, sizeof(marked));
  mark(begin1, delta1, marked[0]);
  mark(begin2, delta2, marked[1]);
  finish[0] = n, finish[1] = n;
  for (int i = 0; i < n - 1; ++i)
    if (marked[0][i] && marked[1][i])
      if (a[i + 1] - a[i] == delta1)
        finish[1] = min(finish[1], i);
      else
        finish[0] = min(finish[0], i);
  int current1 = begin1, current2 = begin2;
  for (int i = 0; i < n; ++i)
    if (marked[0][i] && (i < finish[0]))
      if (a[i] != current1)
        return;
      else
        current1 += delta1;
    else if (!marked[1][i] || (i >= finish[1]))
      return;
    else
      current2 += delta2;
  output();
}
void run(int begin, int delta) {
  int current = begin, otherbegin = unknown, otherdelta = unknown;
  for (int i = 0; i < n; ++i)
    if (a[i] == current)
      current += delta;
    else if (otherbegin == unknown)
      otherbegin = a[i];
    else if (otherdelta == unknown)
      otherdelta = a[i] - otherbegin;
  if (otherbegin == unknown) {
    finish[0] = finish[1] = n;
    memset(marked, 0, sizeof(marked));
    marked[0][0] = true;
    for (int i = 1; i < n; ++i) marked[1][i] = true;
    output();
  }
  int sign = otherdelta < 0 ? -1 : 1;
  for (int j = 1; j * j <= otherdelta * sign; ++j)
    if (otherdelta % j == 0) {
      build(begin, delta, otherbegin, j * sign);
      build(begin, delta, otherbegin, otherdelta / j);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  run(a[0], a[1] - a[0]);
  run(a[0], a[2] - a[0]);
  run(a[1], a[2] - a[1]);
  printf("No solution\n");
  return 0;
}