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, seq[30100], aux[30100];
int s1, s2, t1, t2, ds, dt, ls, lt;
bool fill(int start) {
  bool ok = true;
  for (int i = start; i < n; i++) {
    if (seq[i] == seq[ls] + ds) {
      ls = i;
      aux[i] = 0;
    } else if (t1 < 0) {
      t1 = i;
      aux[i] = 1;
    } else if (t2 < 0) {
      t2 = i;
      aux[i] = 1;
      dt = seq[t2] - seq[t1];
      lt = t2;
    } else if (ok && seq[i] == seq[lt] + dt) {
      lt = i;
      aux[i] = 1;
    } else {
      aux[i] = 1;
      ok = false;
    }
  }
  if (ok) return true;
  aux[n - 1] = 1;
  aux[n - 2] = 1;
  dt = seq[n - 1] - seq[n - 2];
  lt = n - 2;
  bool allowed = true;
  for (int i = n - 3; i >= 0; i--) {
    if (seq[i] + dt == seq[lt]) {
      if (aux[i] == 1 || allowed) {
        aux[i] = 1;
        lt = i;
      }
    } else if (aux[i] == 0) {
      allowed = false;
    } else {
      return false;
    }
  }
  return true;
}
int main() {
  int i, j, k;
  cin >> n;
  for (i = 0; i < n; i++) cin >> seq[i];
  bool ok = true;
  if (n <= 4) {
    for (i = 0; i < n; i++) aux[i] = i % 2;
  } else {
    aux[0] = 0;
    s1 = 0;
    aux[1] = 0;
    s2 = 1;
    ds = seq[s2] - seq[s1];
    ls = s2;
    t1 = -1;
    t2 = -1;
    dt = -1;
    lt = -1;
    ok = fill(2);
    if (ok) {
      if (t1 < 0) aux[0] = 1;
    } else {
      aux[1] = 1;
      aux[2] = 0;
      s2 = 2;
      ds = seq[s2] - seq[s1];
      ls = s2;
      t1 = 1;
      t2 = -1;
      dt = -1;
      lt = -1;
      ok = fill(3);
      if (!ok) {
        aux[0] = 1;
        aux[1] = 0;
        aux[2] = 0;
        s1 = 1;
        s2 = 2;
        ds = seq[s2] - seq[s1];
        ls = s2;
        t1 = 0;
        t2 = -1;
        dt = -1;
        lt = -1;
        ok = fill(3);
      }
    }
  }
  if (ok) {
    bool fst = true;
    for (i = 0; i < n; i++) {
      if (aux[i] == 0) {
        if (!fst) {
          cout << " ";
        } else {
          fst = false;
        }
        cout << seq[i];
      }
    }
    cout << endl;
    fst = true;
    for (i = 0; i < n; i++) {
      if (aux[i] == 1) {
        if (!fst) {
          cout << " ";
        } else {
          fst = false;
        }
        cout << seq[i];
      }
    }
    cout << endl;
  } else {
    cout << "No solution\n";
  }
  return 0;
}