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 MAXN = 50000;
const int INF = 0x7FFFFFFF;
const double eps = 1e-10;
const double pi = acos(-1.0);
int n, tot1, tot2;
int a[MAXN], A[MAXN], B[MAXN], C[MAXN];
map<int, pair<int, int> > number;
void init() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
}
bool check(int x, int y) {
  number.clear();
  for (int i = 0; i < n; i++) number[a[i]] = make_pair(i, 1);
  tot1 = tot2 = 0;
  A[tot1++] = a[x];
  A[tot1++] = a[y];
  number[a[x]].second = 0;
  number[a[y]].second = 0;
  int delta = A[1] - A[0];
  int pre = number[a[y]].first;
  while (true) {
    int next = A[tot1 - 1] + delta;
    if (number[next].second == 0 || number[next].first < pre) break;
    --number[next].second;
    pre = number[next].first;
    A[tot1++] = next;
  }
  for (int i = 0; i < n; i++)
    if (number[a[i]].second > 0) B[tot2++] = a[i];
  bool flag = true;
  for (int i = 1; i < tot2 - 1; i++)
    if (abs(B[i] - B[i - 1]) != abs(B[i + 1] - B[i])) {
      flag = false;
      break;
    }
  if (flag) return true;
  number.clear();
  {
    number.clear();
    for (int i = 0; i < tot1; i++) number[A[i]] = make_pair(i, 1);
    int delta = INF;
    for (int i = 1; i < tot2; i++)
      if (abs(B[i] - B[i - 1]) < abs(delta)) delta = B[i] - B[i - 1];
    int now = B[0], tot3 = 1, tot4 = tot1, pre = -1, k = 1;
    C[0] = B[0];
    for (int i = 1;; i++) {
      now += delta;
      if (B[k] != now) {
        if (pre == tot4 - 1) break;
        if (number[now].second > 0) {
          if (number[now].first < pre) return false;
          if (pre == -1) tot1 = number[now].first;
          pre = number[now].first;
          C[tot3++] = now;
        } else
          return false;
      } else {
        C[tot3++] = B[k++];
      }
    }
    tot2 = tot3;
    if (tot1 + tot2 != n) return false;
    for (int i = 0; i < tot3; i++) B[i] = C[i];
    return true;
  }
  return true;
}
void solve() {
  bool flag = true;
  for (int i = 1; i < n - 1; i++)
    if (a[i] - a[i - 1] != a[i + 1] - a[i]) {
      flag = false;
      break;
    }
  if (flag) {
    cout << a[0] << endl;
    for (int i = 1; i < n; i++) {
      if (i > 1) cout << ' ';
      cout << a[i];
    }
    cout << endl;
    return;
  }
  flag = check(0, 1) || check(1, 2) || check(0, 2);
  if (!flag)
    cout << "No solution" << endl;
  else {
    for (int i = 0; i < tot1; i++) {
      if (i > 0) cout << ' ';
      cout << A[i];
    }
    cout << endl;
    for (int i = 0; i < tot2; i++) {
      if (i > 0) cout << ' ';
      cout << B[i];
    }
    cout << endl;
  }
}
int main() {
  init();
  solve();
  return 0;
}