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;
vector<int> A;
const int MAXLEN = 50001;
const int INF = -2147483647;
ostream &operator<<(ostream &stream, vector<int> &p) {
  for (int i = 0; i < p.size(); i++) cout << p[i] << " ";
  return stream;
}
bool proverka(vector<int> &A, vector<int> &p1, vector<int> &p2, int f, int s) {
  p1.clear();
  p2.clear();
  p2.assign(MAXLEN, INF);
  int d1, d2;
  d1 = A[s] - A[f];
  p1.push_back(A[f]);
  p1.push_back(A[s]);
  vector<int> p1s, p2s;
  int last_element = A[s];
  int last_element_2;
  bool first_element = false;
  bool second_element = false;
  bool other_variant = false;
  int k1, k2;
  int last_position = 0;
  for (int i = 0; i < A.size(); i++) {
    int cur = A[i];
    if (i == s || i == f) continue;
    if (cur - last_element == d1 && first_element && !second_element && i > s) {
      p1.push_back(cur);
      p1s.push_back(i);
      last_element = cur;
      other_variant = true;
      k2 = i;
    } else if (cur - last_element == d1 && i > s) {
      p1.push_back(cur);
      p1s.push_back(i);
      last_element = cur;
    } else if (!first_element) {
      first_element = true;
      p2[0] = cur;
      p2s.push_back(i);
      last_element_2 = p2[0];
      last_position = 1;
      k1 = i;
    } else if (!second_element) {
      second_element = true;
      p2[1] = cur;
      d2 = p2[1] - p2[0];
      last_position = 2;
      last_element_2 = p2[1];
    } else if ((cur - p2[0]) % d2 == 0) {
      int pos = (cur - p2[0]) / d2;
      if (p2[pos] != INF) {
        if (other_variant) return (proverka(A, p1, p2, k1, k2));
        return false;
      }
      p2[pos] = cur;
      p2s.push_back(i);
      if (pos + 1 > last_position)
        last_position = pos + 1;
      else {
        if (other_variant) return (proverka(A, p1, p2, k1, k2));
        return false;
      }
    } else {
      if (other_variant) return (proverka(A, p1, p2, k1, k2));
      return false;
    }
  }
  p2.resize(last_position);
  for (int i = last_position - 1; i >= 0; i--) {
    if (p2[i] == INF && p1.size() > 1) {
      int pback = p1.back();
      if (((pback - p2[0]) % d2 == 0) && ((pback - p2[0]) / d2 == i)) {
        p2[i] = p1.back();
        p1.pop_back();
      } else {
        if (other_variant) return (proverka(A, p1, p2, k1, k2));
        return false;
      }
    }
    if (p2[i] == INF && !p1.size() > 1) {
      if (other_variant) return (proverka(A, p1, p2, k1, k2));
      return false;
    }
  }
  if (last_position + p1.size() != A.size()) {
    if (other_variant) return (proverka(A, p1, p2, k1, k2));
    return false;
  }
  if (p2.empty() && p1.size() > 1) {
    p2.push_back(p1.back());
    p1.pop_back();
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  A.resize(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  if (n == 3) {
    cout << A[0] << endl << A[1] << " " << A[2] << endl;
    return 0;
  }
  if (n == 2) {
    cout << A[0] << endl << A[1] << endl;
    return 0;
  }
  vector<int> p1, p2;
  if (proverka(A, p1, p2, 0, 1)) {
    cout << p1 << endl << p2 << endl;
  } else if (proverka(A, p1, p2, 0, 2)) {
    cout << p1 << endl << p2 << endl;
  } else if (proverka(A, p1, p2, 1, 2)) {
    cout << p1 << endl << p2 << endl;
  } else {
    cout << "No solution" << endl;
  }
  return 0;
}