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 n;
int a[200000];
int col[200000];
vector<int> f, s, q, w;
void output() {
  if (!s.size()) s.push_back(f.back()), f.pop_back();
  if (!f.size()) f.push_back(s.back()), s.pop_back();
  for (int i = 0; i < f.size(); i++)
    printf("%d%c", f[i], " \n"[i + 1 == f.size()]);
  for (int i = 0; i < s.size(); i++)
    printf("%d%c", s[i], " \n"[i + 1 == s.size()]);
  exit(0);
}
void test() {
  int id[2] = {};
  f.clear();
  s.clear();
  for (int i = 0; i < n; i++) {
    if (col[i]) {
      if (col[i] == 1)
        f.push_back(a[i]);
      else
        s.push_back(a[i]);
      id[col[i] - 1]++;
    } else if ((id[1] + 1 >= w.size() || w[id[1]] != a[i]) &&
               id[0] < q.size() && q[id[0]] == a[i]) {
      f.push_back(a[i]);
      id[0]++;
    } else if (id[1] < w.size() && w[id[1]] == a[i]) {
      s.push_back(a[i]);
      id[1]++;
    } else
      return;
  }
  output();
}
void check(int u, int r, int v) {
  memset(col, 0, sizeof(col));
  col[u] = col[r] = 1;
  q.clear();
  w.clear();
  int cur = a[u], last = u;
  for (int i = u; i < n; i++)
    if (a[i] == cur) {
      col[i] = 1;
      q.push_back(cur);
      last = i;
      cur += v;
    }
  int j, k;
  for (j = 0; j < n && col[j]; j++)
    ;
  if (j == n) test();
  for (k = j + 1; k < n && col[k]; k++)
    ;
  if (k == n) f = q, s.clear(), s.push_back(a[j]), output();
  for (int i = 0; i < n; i++)
    if (col[i] == 1 && i != u && i != r) col[i] = 0;
  cur = a[j];
  col[j] = col[k] = 2;
  for (int i = j; i < n; i++)
    if (a[i] == cur) {
      w.push_back(cur);
      cur += a[k] - a[j];
    }
  test();
  if (last <= j) return;
  col[k] = 0;
  col[last] = 2;
  cur = a[j];
  w.clear();
  for (int i = j; i < n; i++)
    if (a[i] == cur) {
      w.push_back(cur);
      cur += a[last] - a[j];
    }
  test();
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  check(0, 1, a[1] - a[0]);
  check(0, 2, a[2] - a[0]);
  check(1, 2, a[2] - a[1]);
  puts("No solution");
  return 0;
}