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 arr1[300001] = {0};
int arr2[300001] = {0};
int arr3[300001] = {0};
void printvector(vector<long long int>& vec) {
  for (long long int i = 0; i < vec.size(); i++) cout << vec[i] << ' ';
  cout << endl;
  return;
}
int main() {
  long long int n;
  cin >> n;
  vector<long long int> vec(n);
  vector<long long int> ans1a;
  vector<long long int> ans1b;
  vector<long long int> ans2a;
  vector<long long int> ans2b;
  vector<long long int> ans3a;
  vector<long long int> ans3b;
  for (long long int i = 0; i < n; i++) cin >> vec[i];
  if (n == 1) {
    cout << "No solution" << endl;
    return 0;
  }
  if (n == 2) {
    cout << vec[0] << '\n' << vec[1] << '\n';
    return 0;
  }
  long long int a = vec[vec.size() - 3];
  long long int b = vec[vec.size() - 2];
  long long int c = vec[vec.size() - 1];
  long long int r1 = c - a;
  long long int ini1 = vec.size() - 1;
  long long int r2 = c - b;
  long long int ini2 = vec.size() - 1;
  long long int r3 = b - a;
  long long int ini3 = vec.size() - 2;
  arr1[ini1] = 1;
  arr2[ini2] = 1;
  arr3[ini3] = 1;
  long long int curr = ini1;
  for (long long int i = ini1 - 1; i >= 0; i--) {
    if (vec[curr] - vec[i] == r1) {
      curr = i;
      arr1[i] = 1;
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (arr1[i]) {
      ans1a.push_back(vec[i]);
    } else {
      ans1b.push_back(vec[i]);
    }
  }
  bool pos1 = true;
  if (ans1b.size() == 1) {
    pos1 = true;
  } else if (ans1b.size() == 0) {
    pos1 = false;
  } else {
    long long int r11 = ans1b[1] - ans1b[0];
    for (long long int i = 1; i < ans1b.size(); i++) {
      if (ans1b[i] - ans1b[i - 1] != r11) {
        pos1 = false;
        break;
      }
    }
  }
  if (pos1 == true) {
    for (long long int i = 0; i < ans1a.size(); i++) cout << ans1a[i] << ' ';
    cout << endl;
    for (long long int i = 0; i < ans1b.size(); i++) cout << ans1b[i] << ' ';
    cout << endl;
    return 0;
  }
  curr = ini2;
  for (long long int i = ini2 - 1; i >= 0; i--) {
    if (vec[curr] - vec[i] == r2) {
      curr = i;
      arr2[i] = 1;
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (arr2[i]) {
      ans2a.push_back(vec[i]);
    } else {
      ans2b.push_back(vec[i]);
    }
  }
  bool pos2 = true;
  if (ans2b.size() == 1) {
    pos2 = true;
  } else if (ans2b.size() == 0) {
    pos2 = false;
  } else {
    long long int r22 = ans2b[1] - ans2b[0];
    for (long long int i = 1; i < ans2b.size(); i++) {
      if (ans2b[i] - ans2b[i - 1] != r22) {
        pos2 = false;
        break;
      }
    }
  }
  if (pos2 == true) {
    for (long long int i = 0; i < ans2a.size(); i++) cout << ans2a[i] << ' ';
    cout << endl;
    for (long long int i = 0; i < ans2b.size(); i++) cout << ans2b[i] << ' ';
    cout << endl;
    return 0;
  }
  curr = ini3;
  for (long long int i = ini3 - 1; i >= 0; i--) {
    if (vec[curr] - vec[i] == r3) {
      curr = i;
      arr3[i] = 1;
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (arr3[i]) {
      ans3a.push_back(vec[i]);
    } else {
      ans3b.push_back(vec[i]);
    }
  }
  bool pos3 = true;
  if (ans3b.size() == 1) {
    pos3 = true;
  } else if (ans3b.size() == 0) {
    pos3 = false;
  } else {
    long long int r33 = ans3b[1] - ans3b[0];
    for (long long int i = 1; i < ans3b.size(); i++) {
      if (ans3b[i] - ans3b[i - 1] != r33) {
        pos3 = false;
        break;
      }
    }
  }
  if (pos3 == true) {
    for (long long int i = 0; i < ans3a.size(); i++) cout << ans3a[i] << ' ';
    cout << endl;
    for (long long int i = 0; i < ans3b.size(); i++) cout << ans3b[i] << ' ';
    cout << endl;
    return 0;
  }
  cout << "No solution" << endl;
  return 0;
}