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 main() {
  long long a;
  cin >> a;
  vector<long long> novo(a + 1);
  vector<long long> blanco;
  vector<long long> vec;
  vector<long long> estado(a + 1);
  for (long long i = 0; i < a; i++) {
    long long g;
    cin >> g;
    vec.push_back(g);
  }
  if (vec.size() == 2) {
    cout << vec[0] << endl;
    cout << vec[1] << endl;
    return 0;
  }
  if (vec.size() == 3) {
    cout << vec[0] << " " << vec[1] << endl;
    cout << vec[2] << endl;
    return 0;
  }
  if (vec.size() == 4) {
    cout << vec[0] << " " << vec[1] << endl;
    cout << vec[2] << " " << vec[3] << endl;
    return 0;
  }
  long long r1 = vec[vec.size() - 1] - vec[vec.size() - 2];
  long long r2 = vec[vec.size() - 1] - vec[vec.size() - 3];
  long long r3 = vec[vec.size() - 2] - vec[vec.size() - 3];
  long long x = vec.size() - 2;
  estado[vec.size() - 1] = 1;
  ;
  long long tmp = vec[vec.size() - 1];
  while (x < vec.size() - 1 and x >= 0) {
    if (vec[x] == tmp - r1) {
      estado[x] = 1;
      tmp = tmp - r1;
    }
    x--;
  }
  vector<long long> arr;
  vector<long long> margi;
  for (long long i = 0; i < a; i++) {
    if (estado[i] == 0) {
      arr.push_back(vec[i]);
    } else {
      margi.push_back(vec[i]);
    }
  }
  long long y = 0;
  if (arr.size() == 0) {
    y++;
  } else if (arr.size() != 1) {
    long long razon = arr[1] - arr[0];
    for (long long i = 1; i < arr.size(); i++) {
      if (arr[i] - arr[i - 1] != razon) {
        y++;
      }
    }
  }
  if (y == 0) {
    for (long long i = 0; i < margi.size() - 1; i++) {
      cout << margi[i] << " ";
    }
    cout << margi[margi.size() - 1] << endl;
    for (long long i = 0; i < arr.size() - 1; i++) {
      cout << arr[i] << " ";
    }
    cout << arr[arr.size() - 1] << endl;
    return 0;
  }
  estado = novo;
  x = vec.size() - 3;
  estado[vec.size() - 1] = 1;
  ;
  tmp = vec[vec.size() - 1];
  while (x < vec.size() - 1 and x >= 0) {
    if (vec[x] == tmp - r2) {
      estado[x] = 1;
      tmp = tmp - r2;
    }
    x--;
  }
  arr = blanco;
  margi = blanco;
  for (long long i = 0; i < vec.size(); i++) {
    if (estado[i] == 0) {
      arr.push_back(vec[i]);
    } else {
      margi.push_back(vec[i]);
    }
  }
  y = 0;
  if (arr.size() == 0) {
    y++;
  } else if (arr.size() != 1) {
    long long razon = arr[1] - arr[0];
    for (long long i = 1; i < arr.size(); i++) {
      if (arr[i] - arr[i - 1] != razon) {
        y++;
      }
    }
  }
  if (y == 0) {
    for (long long i = 0; i < margi.size() - 1; i++) {
      cout << margi[i] << " ";
    }
    cout << margi[margi.size() - 1] << endl;
    for (long long i = 0; i < arr.size() - 1; i++) {
      cout << arr[i] << " ";
    }
    cout << arr[arr.size() - 1] << endl;
    return 0;
  }
  estado = novo;
  x = vec.size() - 3;
  estado[vec.size() - 2] = 1;
  ;
  tmp = vec[vec.size() - 2];
  while (x < vec.size() - 1 and x >= 0) {
    if (vec[x] == tmp - r3) {
      estado[x] = 1;
      tmp = tmp - r3;
    }
    x--;
  }
  arr = blanco;
  margi = blanco;
  for (long long i = 0; i < vec.size(); i++) {
    if (estado[i] == 0) {
      arr.push_back(vec[i]);
    } else {
      margi.push_back(vec[i]);
    }
  }
  y = 0;
  if (arr.size() != 1) {
    long long razon = arr[1] - arr[0];
    for (long long i = 1; i < arr.size(); i++) {
      if (arr[i] - arr[i - 1] != razon) {
        y++;
      }
    }
  }
  if (arr.size() == 0) {
    y++;
  } else if (y == 0) {
    for (long long i = 0; i < margi.size() - 1; i++) {
      cout << margi[i] << " ";
    }
    cout << margi[margi.size() - 1] << endl;
    for (long long i = 0; i < arr.size() - 1; i++) {
      cout << arr[i] << " ";
    }
    cout << arr[arr.size() - 1] << endl;
    return 0;
  }
  cout << "No solution" << endl;
  return 0;
}