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;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
int n;
int a[N];
int id[N];
pair<int, int> upto[N];
vector<int> aa, bb;
int d[3];
bool check(int i) {
  if (i > n) return aa.size() and bb.size();
  if (i == n) {
    if (d[2] == oo or bb.back() + d[2] == a[n]) {
      bb.push_back(a[n]);
      return 1;
    } else if (d[1] + aa.back() == a[n]) {
      aa.push_back(a[n]);
      return bb.size();
    } else
      return 0;
  }
  if (upto[i].first and (upto[i].second == d[2] or d[2] == oo) and
      (bb.empty() or a[i] - bb.back() == upto[i].second)) {
    for (; i <= n; i++) bb.push_back(a[i]);
    return 1;
  }
  if (a[i] == aa.back() + d[1]) {
    aa.push_back(a[i]);
    return check(i + 1);
  } else {
    if (d[2] == oo or (d[2] == a[i] - bb.back())) {
      if (bb.size() == 1) d[2] = a[i] - (bb.empty() ? 0 : bb.back());
      bb.push_back(a[i]);
      return check(i + 1);
    } else
      return 0;
  }
  return 0;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  upto[n] = {1, oo};
  upto[n - 1] = {1, a[n] - a[n - 1]};
  for (int i = n - 2; i >= 1; i--) {
    upto[i] = {upto[i + 1].first and a[i + 1] - a[i] == upto[i + 1].second,
               upto[i + 1].second};
  }
  if (n == 2) {
    cout << a[1] << '\n' << a[2] << '\n';
    return 0;
  }
  for (int i = 1; i <= 3; i++) {
    for (int j = i + 1; j <= 3; j++) {
      aa.clear();
      bb.clear();
      int x = j + 1;
      if (j == 3) bb.push_back(a[(i == 1) + 1]);
      aa.push_back(a[i]);
      aa.push_back(a[j]);
      d[1] = a[j] - a[i];
      d[2] = oo;
      if (check(x)) {
        for (int i : aa) cout << i << " ";
        cout << "\n";
        for (int i : bb) cout << i << " ";
        cout << "\n";
        return 0;
      }
    }
  }
  cout << "No solution\n";
}