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 long long maxn = 30010;
const long long mod = 1e15 + 7;
long long a[maxn];
bool mark[maxn];
bool ok[maxn];
void gos(long long n, long long d, long long h) {
  long long last = h;
  memset(mark, 0, sizeof(mark));
  for (long long i = 0; i < n - 2; i++) {
    if (last == a[i]) {
      mark[i] = 1;
      last += d;
    }
    if (i == 0) {
      ok[i] = mark[i];
    } else {
      ok[i] = (ok[i - 1] & mark[i]);
    }
  }
  d = (a[n - 1] - a[n - 2]);
  long long ex = a[n - 2] - d;
  bool jelo = 0;
  for (long long i = n - 3; i >= 0; i--) {
    if (ok[i]) {
      break;
    }
    if (a[i] == ex) {
      if (mark[i] && jelo) {
        return;
      }
      mark[i] = 0;
      ex -= d;
    } else {
      if (mark[i]) {
        jelo = 1;
      } else {
        return;
      }
    }
  }
  d = 0;
  for (long long i = 0; i < n; i++) d += mark[i];
  if (d == n || d == 0) {
    mark[0] = !mark[0];
  }
  for (long long i = 0; i < n; i++) {
    if (mark[i]) {
      cout << a[i] << ' ';
    }
  }
  cout << endl;
  for (long long i = 0; i < n; i++) {
    if (!mark[i]) {
      cout << a[i] << ' ';
    }
  }
  cout << endl;
  exit(0);
}
void god(long long n, long long d, long long h) {
  long long last = h;
  memset(mark, 0, sizeof(mark));
  for (long long i = 0; i < n; i++) {
    if (last == a[i]) {
      mark[i] = 1;
      last += d;
    }
  }
  last = -mod;
  d = -mod;
  for (long long i = 0; i < n; i++) {
    if (!mark[i]) {
      if (last == -mod) {
        last = a[i];
      } else {
        if (d == -mod) {
          d = a[i] - last;
          last = a[i];
        } else {
          if (a[i] != last + d) {
            return;
          } else {
            last = a[i];
          }
        }
      }
    }
  }
  d = 0;
  for (long long i = 0; i < n; i++) d += mark[i];
  if (d == n || d == 0) {
    mark[0] = !mark[0];
  }
  for (long long i = 0; i < n; i++) {
    if (mark[i]) {
      cout << a[i] << ' ';
    }
  }
  cout << endl;
  for (long long i = 0; i < n; i++) {
    if (!mark[i]) {
      cout << a[i] << ' ';
    }
  }
  cout << endl;
  exit(0);
}
void good(long long n, long long d) {
  god(n, d, a[0]);
  god(n, d, a[1]);
  gos(n, d, a[0]);
  gos(n, d, a[1]);
}
map<long long, long long> ml;
vector<pair<long long, long long> > vec;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 2) {
    cout << a[0] << '\n' << a[1] << endl;
    return 0;
  }
  set<long long> st;
  for (long long i = 0; i + 2 < n; i++) {
    ml[a[i + 1] - a[i]]++;
    ml[a[i + 2] - a[i]]++;
    ml[a[i + 2] - a[i + 1]]++;
    st.insert(a[i + 1] - a[i]);
    st.insert(a[i + 2] - a[i]);
    st.insert(a[i + 2] - a[i + 1]);
  }
  vector<pair<long long, long long> > vec;
  while (st.size()) {
    long long v = (*st.begin());
    st.erase(v);
    vec.push_back(make_pair(-ml[v], v));
  }
  god(n, a[1] - a[0], a[0]);
  gos(n, a[1] - a[0], a[0]);
  sort(vec.begin(), vec.end());
  for (long long i = 0; i < min((long long)vec.size(), (long long)6); i++) {
    good(n, vec[i].second);
  }
  cout << "No solution";
}