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 a[300005];
vector<int> ans1, ans2;
set<int> s;
map<int, int> id;
void init(int n) {
  s.clear();
  for (int i = 1; i <= n; i++) {
    s.insert(a[i]);
  }
}
void work1(int gap) {
  while (s.find(ans1.back() + gap) != s.end()) {
    if (id[ans1.back() + gap] < id[ans1.back()]) break;
    s.erase(s.lower_bound(ans1.back() + gap));
    ans1.push_back(ans1.back() + gap);
  }
}
void work2(int n) {
  int gap = 0;
  for (int i = 1; i <= n; i++) {
    if (s.find(a[i]) != s.end()) {
      if (ans2.size() > 1) {
        if (a[i] - ans2.back() != gap) {
          if (2 * ans1.back() == a[i] + ans2.back() &&
              id[ans1.back()] > id[ans2.back()] && id[ans1.back()] < id[a[i]]) {
            ans2.push_back(ans1.back());
            ans1.pop_back();
          } else
            break;
        }
      }
      ans2.push_back(a[i]);
      if (ans2.size() == 2) gap = ans2[1] - ans2[0];
    }
  }
  if (ans1.size() + ans2.size() != n) {
    ans2.clear();
    for (int i = 1; i <= n; i++) {
      if (ans2.size() == 1) {
        ans2.push_back(ans1.back());
        ans1.pop_back();
        gap = ans2[1] - ans2[0];
      }
      if (s.find(a[i]) != s.end()) {
        if (ans2.size() > 1) {
          if (a[i] - ans2.back() != gap) {
            return;
          }
        }
        ans2.push_back(a[i]);
      }
    }
  }
}
bool cmp(int a, int b) { return id[a] < id[b]; }
void output() {
  if (ans2.empty()) {
    ans2.push_back(ans1.back());
    ans1.pop_back();
  }
  for (int i = 0; i < ans1.size(); i++) {
    cout << ans1[i];
    if (i == ans1.size() - 1)
      cout << '\n';
    else
      cout << ' ';
  }
  sort(ans2.begin(), ans2.end(), cmp);
  for (int i = 0; i < ans2.size(); i++) {
    cout << ans2[i];
    if (i == ans2.size() - 1)
      cout << '\n';
    else
      cout << ' ';
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    id[a[i]] = i;
  }
  init(n);
  ans1.push_back(a[1]);
  ans1.push_back(a[2]);
  s.erase(a[1]);
  s.erase(a[2]);
  work1(ans1[1] - ans1[0]);
  work2(n);
  if (ans1.size() + ans2.size() == n) {
    output();
    return 0;
  }
  init(n);
  ans1.clear();
  ans2.clear();
  ans1.push_back(a[1]);
  ans1.push_back(a[3]);
  s.erase(a[1]);
  s.erase(a[3]);
  work1(ans1[1] - ans1[0]);
  work2(n);
  if (ans1.size() + ans2.size() == n) {
    output();
    return 0;
  }
  init(n);
  ans1.clear();
  ans2.clear();
  ans1.push_back(a[2]);
  ans1.push_back(a[3]);
  s.erase(a[2]);
  s.erase(a[3]);
  work1(ans1[1] - ans1[0]);
  work2(n);
  if (ans1.size() + ans2.size() == n) {
    output();
    return 0;
  }
  cout << "No solution" << '\n';
  return 0;
}