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 Max = 30010;
int N, A[Max], C[Max], D[Max];
char U[Max];
map<int, int> ms;
map<int, int> value;
inline void remove(int d) {
  if (--ms[d] == 0) ms.erase(d);
}
bool check(int d, set<int> &lt) {
  int c = A[0] + d;
  int dn = 0;
  while (1) {
    int x = value[c];
    if (x == 0 || x < D[dn]) {
      for (int i = dn; i >= 1; i--) {
        x = D[i];
        pair<set<int>::iterator, bool> sb = lt.insert(x);
        set<int>::iterator p = sb.first;
        set<int>::iterator s = p, t = p;
        --s, ++t;
        if (p != lt.begin() && t != lt.end()) remove(A[*t] - A[*s]);
        if (t != lt.end()) ++ms[A[*t] - A[x]];
        if (p != lt.begin()) ++ms[A[x] - A[*s]];
        U[x] = 0;
      }
      return false;
    }
    D[++dn] = --x;
    set<int>::iterator p = lt.find(x);
    set<int>::iterator s = p, t = p;
    --s, ++t;
    U[x] = 1;
    if (p != lt.begin()) remove(A[x] - A[*s]);
    if (t != lt.end()) remove(A[*t] - A[x]);
    if (p != lt.begin() && t != lt.end()) ++ms[A[*t] - A[*s]];
    lt.erase(x);
    if (1 == ms.size()) return true;
    c += d;
  }
}
void out() {
  int f = 0;
  for (int i = 0; i < N; i++)
    if (U[i] == 1) {
      if (f++) putchar(' ');
      printf("%d", A[i]);
    }
  putchar('\n');
  f = 0;
  for (int i = 0; i < N; i++)
    if (U[i] == 0) {
      if (f++) putchar(' ');
      printf("%d", A[i]);
    }
  putchar('\n');
}
int main() {
  for (int i = 0; i < Max; i++) C[i] = i;
  while (scanf("%d", &N) != EOF) {
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    if (N == 2) {
      printf("%d\n%d\n", A[0], A[1]);
      continue;
    }
    value.clear();
    for (int i = 0; i < N; i++) value[A[i]] = i + 1;
    ms.clear();
    for (int i = 2; i < N; i++) ++ms[A[i] - A[i - 1]];
    memset(U, 0, sizeof(U[0]) * N);
    U[0] = 1;
    if (1 == ms.size()) {
      out();
      continue;
    }
    set<int> lt(C + 1, C + N);
    bool find = false;
    for (int i = 1; i < N; i++)
      if (check(A[i] - A[0], lt)) {
        find = true;
        out();
        break;
      }
    if (!find) puts("No solution");
  }
  return 0;
}