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 maxn = 30000 + 10;
int n, top1, top2, d1, d2;
int a[maxn], s1[maxn], s2[maxn];
bool ok[maxn];
inline bool add2(const int &i) {
  if (top2 < 2 || a[i] - a[s2[top2]] == d2) {
    s2[++top2] = i;
    if (top2 == 2) d2 = a[s2[2]] - a[s2[1]];
    return true;
  }
  return false;
}
inline bool all2(int i) {
  if (!ok[i]) return false;
  if (n - i + 1 + top2 <= 2) return true;
  switch (top2) {
    case 0:
      return true;
    case 1:
      return a[n] - a[n - 1] == a[i] - a[s2[top2]];
    default:
      return a[n] - a[n - 1] == d2 && a[n] - a[n - 1] == a[i] - a[s2[top2]];
  }
}
bool check(int h1, int h2) {
  top1 = top2 = 0;
  s1[++top1] = h1, s1[++top1] = h2;
  d1 = a[h2] - a[h1];
  if (h2 == 3) s2[++top2] = 6 - h1 - h2;
  for (int i = h2 == 3 ? 4 : 3; i <= n; ++i)
    if (a[i] - a[s1[top1]] == d1) {
      if (all2(i)) {
        while (i <= n) {
          s2[++top2] = i;
          ++i;
        }
        return true;
      }
      s1[++top1] = i;
    } else if (!add2(i))
      return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  if (n == 2) {
    printf("%d\n%d\n", a[1], a[2]);
    exit(0);
  }
  ok[n] = ok[n - 1] = true;
  for (int i = n - 2; i > 2; ++i)
    if (a[i] + a[i + 2] == 2 * a[i + 1])
      ok[i] = true;
    else
      break;
  if (check(1, 2) || check(1, 3) || check(2, 3)) {
    for (int i = 1; i <= top1; ++i) printf("%d ", a[s1[i]]);
    printf("\n");
    for (int i = 1; i <= top2; ++i) printf("%d ", a[s2[i]]);
    printf("\n");
  } else
    printf("No solution\n");
  return 0;
}