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;
void input(long &n) { scanf("%ld", &n); }
void output(long n) { printf("%ld", n); }
void input(long &n, long a[]) {
  input(n);
  for (long i = 1; i <= n; i++) input(a[i]);
}
bool test(long n, long a[], long id1, long id2, long tid, vector<long> &st1,
          vector<long> &st2) {
  st1.clear();
  st2.clear();
  st1.push_back(a[id1]);
  st1.push_back(a[id2]);
  long isize2;
  if (tid == -1) {
    isize2 = 0;
  } else {
    isize2 = 1;
    st2.push_back(a[tid]);
  }
  long seed = a[id2] - a[id1];
  long seed2 = 0;
  long nextnum2 = 0;
  long nextnum = a[id2] + seed;
  for (long i = id2 + 1; i <= n; i++) {
    if (isize2 >= 2 && a[i] == nextnum && a[i] == nextnum2) {
      if (i == n) {
        nextnum += seed;
        st1.push_back(a[i]);
      } else if (nextnum + seed == a[i + 1]) {
        nextnum += seed;
        st1.push_back(a[i]);
      } else if (nextnum2 + seed2 == a[i + 1]) {
        st2.push_back(a[i]);
        nextnum2 += seed2;
        isize2++;
      } else
        return false;
    } else if (a[i] == nextnum) {
      nextnum += seed;
      st1.push_back(a[i]);
    } else {
      if (isize2 >= 2) {
        if (nextnum2 == a[i]) {
          st2.push_back(a[i]);
          isize2++;
          nextnum2 += seed2;
        } else if (isize2 == 2) {
          st2.push_back(st2[1]);
          isize2++;
          st2[1] = st1.back();
          st1.pop_back();
          if (st2[2] - st2[1] != st2[1] - st2[0]) return false;
          seed2 = st2[2] - st2[1];
          nextnum2 = st2[2] + seed2;
          i--;
        } else
          return false;
      } else {
        st2.push_back(a[i]);
        isize2++;
        if (isize2 == 2) {
          seed2 = st2[1] - st2[0];
          nextnum2 = st2[1] + seed2;
        }
      }
    }
  }
  if (seed == 0 && st1.size() > 2) return false;
  if (seed2 == 0 && st2.size() > 2) return false;
  if (isize2 == 0) return false;
  return true;
}
bool solve(long n, long a[], vector<long> &st1, vector<long> &st2) {
  if (n == 2) {
    st1.push_back(a[1]);
    st2.push_back(a[2]);
    return true;
  } else if (n == 3 && a[1] == a[2] && a[2] == a[3]) {
    st1.push_back(a[1]);
    st1.push_back(a[1]);
    st2.push_back(a[1]);
    return true;
  } else if (n == 4 && a[1] == a[2] && a[2] == a[3] && a[3] == a[4]) {
    st1.push_back(a[1]);
    st1.push_back(a[1]);
    st2.push_back(a[1]);
    st2.push_back(a[1]);
    return true;
  }
  if (test(n, a, 1, 3, 2, st1, st2)) return true;
  if (test(n, a, 2, 3, 1, st1, st2)) return true;
  if (test(n, a, 1, 2, -1, st1, st2)) return true;
  return false;
}
void output(bool res, vector<long> &st1, vector<long> &st2) {
  if (res) {
    for (vector<long>::iterator it = st1.begin(); it < st1.end(); it++)
      printf("%ld ", *it);
    printf("\n");
    for (vector<long>::iterator it = st2.begin(); it < st2.end(); it++)
      printf("%ld ", *it);
  } else
    cout << "No solution\n";
}
long n, a[30010 + 1];
vector<long> st1, st2;
int main() {
  input(n, a);
  bool res = solve(n, a, st1, st2);
  output(res, st1, st2);
}