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 INF = 1000000000;
const int MAXN = 30005;
int lst[MAXN], N;
bool ok(vector<int> &v) {
  if ((int)v.size() <= 2) return true;
  for (int i = (int)v.size() - 2; i >= max(1, (int)v.size() - 4); i--)
    if (v[i + 1] - v[i] != v[1] - v[0]) return false;
  return true;
}
bool check(vector<int> &a, vector<int> &b, int n) {
  if ((int)a.size() < 2) {
    b.push_back(lst[n]);
    if (!ok(b)) {
      b.erase(b.end() - 1);
      a.push_back(lst[n]);
    }
  } else if ((int)b.size() < 2) {
    a.push_back(lst[n]);
    if (!ok(a)) {
      a.erase(a.end() - 1);
      b.push_back(lst[n]);
    }
  } else {
    a.push_back(lst[n]);
    if (!ok(a)) {
      a.erase(a.end() - 1);
      b.push_back(lst[n]);
    }
  }
  return ok(a) && ok(b);
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> lst[i];
  int sz = min(6, N);
  vector<int> x, y;
  for (int mask = 0; mask < (1 << sz); mask++) {
    vector<int> a, b;
    for (int i = 0; i < sz; i++) {
      if (mask & (1 << i))
        a.push_back(lst[i]);
      else
        b.push_back(lst[i]);
    }
    if (!ok(a) || !ok(b)) continue;
    bool k = true;
    for (int i = sz; i < N; i++) {
      if (!check(a, b, i)) {
        k = false;
        break;
      }
    }
    if (k) {
      x = a, y = b;
      break;
    }
  }
  if ((int)x.size() == 0 && (int)y.size() > 0) {
    x.push_back(y[(int)y.size() - 1]);
    y.erase(y.end() - 1);
  } else if ((int)y.size() == 0 && (int)x.size() > 0) {
    y.push_back(x[(int)x.size() - 1]);
    x.erase(x.end() - 1);
  }
  if ((int)x.size() == 0 && (int)y.size() == 0) {
    cout << "No solution" << endl;
    return 0;
  }
  for (int i = 0; i < (int)x.size(); i++) cout << x[i] << " ";
  cout << endl;
  for (int i = 0; i < (int)y.size(); i++) cout << y[i] << " ";
  cout << endl;
}