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;
int n, a[30001], b[30001], c[30001];
int input() {
  cin >> n;
  for (int i = (int)(0); i <= (int)(n - 1); i++) cin >> a[i];
  return 0;
}
int findTerms(int i, int x1, int x2, int dx, int y1, int y2, int dy, int l1,
              int l2) {
  int d, rv;
  if (i == n) return 0;
  b[i] = 0;
  d = a[i] - a[x2];
  if (d == dx) {
    b[i] = 1;
    rv = findTerms(i + 1, x2, i, dx, y1, y2, dy, l1 + 1, l2);
    if (rv >= 0) return rv + 1;
    b[i] = 0;
    if (rv == -2) return rv;
  }
  if (y1 > 0 && dy != (a[i] - a[y2])) return -1;
  if (y1 <= 0 && y2 > 0) dy = a[i] - a[y2];
  rv = findTerms(i + 1, x1, x2, dx, y2, i, dy, l1, l2 + 1);
  if (rv < 0) rv = -2;
  return rv;
}
int solve() {
  int y0, y1, y2, d1, d2, sec, rv, l1, l2;
  for (sec = 0; sec < n; sec++) {
    b[0] = b[sec] = 1;
    d1 = a[sec] - a[0];
    y2 = sec - 1;
    y1 = sec - 2;
    y0 = sec - 3;
    if (y1 > 0 && y2 > 0) d2 = a[y2] - a[y1];
    if (y0 > 0 && (a[y1] - a[y0]) != d2) {
      sec = n;
      break;
    }
    l1 = sec ? 2 : 1;
    l2 = sec - l1;
    rv = findTerms(sec + 1, 0, sec, d1, y1, y2, d2, l1, l2);
    if (rv >= 0) break;
    b[0] = b[sec] = 0;
  }
  if (sec == n) {
    cout << "No solution\n";
  } else {
    for (int i = (int)(0); i <= (int)(n - 1); i++)
      if (b[i]) cout << a[i] << " ";
    cout << endl;
    for (int i = (int)(0); i <= (int)(n - 1); i++)
      if (!b[i]) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
int main() {
  input();
  solve();
  return 0;
}