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 int maxn = 3e5 + 12, infn = -2e18;
map<long long int, int> m;
long long int n, a[maxn];
bool mark[maxn];
int mark2[maxn];
long long int bmm(long long int x, long long int y) {
  if (!y) return x;
  return bmm(y, x % y);
}
bool check(int st1, int st2) {
  memset(mark, false, sizeof(mark));
  memset(mark2, 0, sizeof(mark2));
  mark[st1] = true;
  mark[st2] = true;
  long long int f1 = a[st1], f2 = a[st2], p = st2;
  while (m[2 * f2 - f1] > p) {
    long long int r = f1;
    f1 = f2;
    f2 = 2 * f2 - r;
    p = m[f2];
    mark[p] = true;
  }
  long long int l1 = infn, k, st, cnt, l2 = infn, last;
  bool b = true;
  for (int i = 1; i < n + 1; i++) {
    if (!mark[i]) {
      if (l1 == infn) {
        l1 = a[i];
        st = i;
      } else if (l2 == infn) {
        l2 = a[i];
        k = a[i] - l1;
        last = a[i];
      } else {
        if (2 * l2 - l1 == a[i]) {
          long long int r = l1;
          l1 = l2;
          l2 = 2 * l2 - r;
        } else
          b = false;
        k = bmm(k, a[i] - last);
        last = a[i];
      }
      cnt++;
    }
  }
  if (!b) {
    l1 = a[st];
    mark2[st] = 1;
    cnt--;
    int h = 0;
    while (m[l1 + k] > st) {
      l1 += k;
      if (mark[m[l1]] && !h)
        h = m[l1];
      else
        cnt--;
      st = m[l1];
      mark2[m[l1]] = 1;
    }
    long long int f1 = a[st1], f2 = a[st2], p = st2;
    mark2[st1] = 2;
    mark2[st2] = 2;
    while (m[2 * f2 - f1] > p && m[2 * f2 - f1] < h) {
      long long int r = f1;
      f1 = f2;
      f2 = 2 * f2 - r;
      p = m[f2];
      mark2[p] = 2;
    }
    for (int i = 1; i < n + 1; i++) {
      if (!mark2[i]) {
        return false;
      }
    }
    for (int i = 1; i < n + 1; i++)
      if (mark2[i] == 1) cout << a[i] << " ";
    cout << endl;
    for (int i = 1; i < n + 1; i++)
      if (mark2[i] == 2) cout << a[i] << " ";
    cout << endl;
    return true;
  }
  if (l1 == infn || !k)
    for (int i = 2; i < n + 1; i++) mark[i] = false;
  for (int i = 1; i < n + 1; i++)
    if (mark[i]) cout << a[i] << " ";
  cout << endl;
  for (int i = 1; i < n + 1; i++)
    if (!mark[i]) cout << a[i] << " ";
  cout << endl;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    m[a[i]] = i;
  }
  if (check(1, 2))
    ;
  else if (check(1, 3))
    ;
  else if (check(2, 3))
    ;
  else
    cout << "No solution" << endl;
  return 0;
}