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 int MOD = 1e6 + 7;
const int INF = 1e9;
const long long LINF = 1e18;
const int WOW = 40000;
const int NIL = 0;
const int dy[8] = {0, 0, -1, 1, 1, 1, -1, -1};
const int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
const double PI = 2 * acos(0);
const int MAXN = 30005;
int N;
int arr[MAXN];
bool vi[MAXN];
void print() {
  vector<int> a, b;
  for (int i = 0; i < N; ++i)
    if (vi[i])
      a.push_back(arr[i]);
    else
      b.push_back(arr[i]);
  if (!b.size()) {
    b.push_back(a.back());
    a.pop_back();
  }
  for (int v : a) printf("%d ", v);
  puts("");
  for (int v : b) printf("%d ", v);
  puts("");
  exit(0);
}
bool go2() {
  int a = INF, b = INF, last;
  for (int i = 0; i < N; ++i) {
    if (vi[i]) continue;
    if (a == INF) {
      a = arr[i];
      continue;
    }
    if (b == INF) {
      b = arr[i];
      last = b;
      continue;
    }
    if (arr[i] - last != b - a) return 0;
    last = arr[i];
  }
  return 1;
}
void go(int a, int b) {
  memset(vi, 0, sizeof(vi));
  vi[a] = vi[b] = 1;
  int nxt = arr[b] * 2 - arr[a];
  int last = b;
  for (int i = b + 1; i < N; ++i)
    if (arr[i] == nxt) nxt += arr[b] - arr[a], last = i, vi[i] = 1;
  if (go2()) print();
  vi[last] = 0;
  if (go2()) print();
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d", &arr[i]);
  if (N == 2) {
    printf("%d\n%d\n", arr[0], arr[1]);
    return 0;
  }
  go(0, 1);
  go(0, 2);
  go(1, 2);
  puts("No solution");
}