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;
const long long LINF = ~(((long long)0x1) << 63) / 2;
const int INF = 0X3F3F3F3F;
const double eps = 1e-7;
int a[50000];
int ok[50000];
int n;
vector<int> first, second;
bool solve(int pree, int pre) {
  int i, j, k, last;
  memset(ok, 0, sizeof(ok));
  ok[pree] = ok[pre] = 1;
  int m = 2;
  first.clear();
  first.push_back(pree);
  first.push_back(pre);
  second.clear();
  for (i = pre + 1; i < n; i++)
    if (a[i] - a[pre] == a[pre] - a[pree]) {
      ok[i] = 1;
      pree = pre;
      pre = i;
      first.push_back(i);
      m++;
    }
  if (m == n) {
    ok[pre] = 0;
    return true;
  }
  pre = -1;
  pree = -1;
  int preee = -1;
  for (i = 0; i < n; i++)
    if (!ok[i] && preee == -1)
      preee = i;
    else if (!ok[i] && pree == -1) {
      pree = i;
    } else if (!ok[i] && pre == -1) {
      pre = i;
      break;
    }
  if (pre == -1 || pree == -1) return true;
  vector<int> now;
  int c = -1;
  bool flag = false;
  if (abs(a[pre] - a[pree]) != abs(a[pree] - a[preee]) &&
      ((a[pre] - a[pree]) % (a[pree] - a[preee]) != 0 &&
       (a[pree] - a[preee]) % (a[pre] - a[pree]) != 0))
    return false;
  if (abs(a[pre] - a[pree]) > abs(a[pree] - a[preee])) {
    c = a[pree] - a[preee];
    for (i = pree + 1; i < pre; i++)
      if (a[pree] + c == a[i]) {
        now.push_back(i);
        pree = i;
      }
    if (a[pree] + c != a[pre]) return false;
  } else if (abs(a[pre] - a[pree]) < abs(a[pree] - a[preee])) {
    c = a[pre] - a[pree];
    for (i = preee + 1; i < pree; i++)
      if (a[preee] + c == a[i]) {
        now.push_back(i);
        preee = i;
      }
    if (a[preee] + c != a[pree]) return false;
  }
  second.push_back(pree);
  second.push_back(pre);
  for (i = pre + 1; i < n; i++)
    if (!ok[i] && a[i] - a[pre] != a[pre] - a[pree]) {
      break;
    } else if (!ok[i]) {
      pree = pre;
      pre = i;
      second.push_back(i);
    } else if (ok[i] && a[i] - a[pre] == a[pre] - a[pree]) {
      pree = pre;
      pre = i;
      now.push_back(i);
      second.push_back(i);
    }
  if (i != n) return false;
  m = now.size();
  int cur = second.size() - 1;
  for (i = m - 1; i >= 0; i--) {
    if (second[cur] != now[i])
      break;
    else
      cur--;
  }
  cur = first.size() - 1;
  for (; i >= 0; i--) {
    if (first[cur] != now[i])
      return false;
    else {
      ok[now[i]] = 0;
      cur--;
    }
  }
  return true;
}
void print() {
  int i;
  for (i = 0; i < n; i++)
    if (ok[i]) {
      cout << a[i];
      break;
    }
  for (i = i + 1; i < n; i++)
    if (ok[i]) cout << " " << a[i];
  cout << endl;
  for (i = 0; i < n; i++)
    if (!ok[i]) {
      cout << a[i];
      break;
    }
  for (i = i + 1; i < n; i++)
    if (!ok[i]) cout << " " << a[i];
  cout << endl;
}
int main() {
  int i, j, k;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  if (solve(0, 1)) {
    print();
  } else if (solve(0, 2)) {
    print();
  } else if (solve(1, 2)) {
    print();
  } else
    printf("No solution\n");
  return 0;
}