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>
int solve(int a[], int na, int b[], int *pnb, int c[], int *pnc);
void write(int a[], int n);
int a[30000];
int b[30000];
int c[30000];
int na, nb, nc;
int main() {
  int i;
  scanf("%d", &na);
  for (i = 0; i < na; i++) scanf("%d", &a[i]);
  if (solve(a, na, b, &nb, c, &nc)) {
    write(b, nb);
    write(c, nc);
  } else {
    printf("No solution\n");
  }
  return 0;
}
void write(int a[], int n) {
  int i;
  for (i = 0; i < n; i++) printf("%d ", a[i]);
  printf("\n");
}
int try_merge(int a[], int na, int b[], int *pnb, int c[], int *pnc) {
  int nb = *pnb;
  int nc = *pnc;
  int i;
  int diff_b;
  int diff_c;
  int t[30000];
  int nt;
  if (b[nb - 2] > c[nc - 1]) {
    return 0;
  }
  diff_b = a[b[1]] - a[b[0]];
  if (b[nb - 1] > c[nc - 1]) {
    diff_c = a[b[nb - 1]] - a[c[nc - 1]];
    c[nc++] = b[--nb];
  } else if (b[nb - 1] < c[nc - 2]) {
    diff_c = a[c[nc - 1]] - a[c[nc - 2]];
  } else {
    diff_c = a[c[nc - 1]] - a[b[nb - 1]];
  }
  nt = 0;
  t[nt++] = c[nc - 1];
  for (i = nc - 2; i >= 0; i--) {
    if (a[c[i + 1]] - a[c[i]] != diff_c) {
      if (a[c[i + 1]] - a[c[i]] != diff_c * 2) return 0;
      if (nb > 2 && b[nb - 1] > c[i] && b[nb - 1] < c[i + 1] &&
          a[c[i + 1]] - a[b[nb - 1]] == diff_c) {
        t[nt++] = b[--nb];
      } else {
        return 0;
      }
    }
    t[nt++] = c[i];
  }
  nc = 0;
  for (i = nt - 1; i >= 0; i--) c[nc++] = t[i];
  *pnc = nc;
  *pnb = nb;
  return 1;
}
int try_add(int a[], int na, int b[], int *pnb, int c[], int *pnc) {
  int diff_b = a[b[1]] - a[b[0]];
  int diff_c;
  int i;
  int nb = *pnb;
  int nc = *pnc;
  int start = nb + nc;
  int flag;
  int up, down;
  for (i = start; i < na; i++) {
    if (a[i] - a[b[nb - 1]] == diff_b) {
      b[nb++] = i;
    } else {
      c[nc++] = i;
    }
  }
  if (nc == 0) {
    c[0] = b[nb - 2];
    c[1] = b[nb - 1];
    nb -= 2;
    nc = 2;
    *pnb = nb;
    *pnc = nc;
    return 1;
  }
  if (nc == 1) {
    if (b[nb - 1] > c[0])
      c[1] = b[nb - 1];
    else {
      c[1] = c[0];
      c[0] = b[nb - 1];
    }
    nc = 2;
    nb -= 1;
    *pnb = nb;
    *pnc = nc;
    return 1;
  }
  if (nc == 2) {
    *pnb = nb;
    *pnc = nc;
    return 1;
  }
  diff_c = a[c[1]] - a[c[0]];
  flag = 1;
  for (i = 2; i < nc; i++)
    if (a[c[i]] - a[c[i - 1]] != diff_c) flag = 0;
  if (flag) {
    *pnb = nb;
    *pnc = nc;
    return 1;
  }
  up = 0;
  down = 0;
  for (i = 1; i < nc; i++) {
    if (a[c[i]] > a[c[i - 1]])
      up = 1;
    else
      down = 1;
  }
  if (up && down) return 0;
  *pnb = nb;
  *pnc = nc;
  return try_merge(a, na, b, pnb, c, pnc);
}
int solve(int a[], int na, int b[], int *pnb, int c[], int *pnc) {
  if (na < 2) return 0;
  if (na == 2) {
    b[0] = a[0];
    c[0] = a[1];
    *pnb = 1;
    *pnc = 1;
    return 1;
  }
  if (na == 3) {
    b[0] = a[0];
    b[1] = a[1];
    c[0] = a[2];
    *pnb = 2;
    *pnc = 1;
    return 1;
  }
  if (na == 4) {
    b[0] = a[0];
    b[1] = a[1];
    c[0] = a[2];
    c[1] = a[3];
    *pnb = 2;
    *pnc = 2;
    return 1;
  }
  b[0] = 0;
  b[1] = 1;
  *pnb = 2;
  *pnc = 0;
  if (try_add(a, na, b, pnb, c, pnc)) {
    int i;
    for (i = 0; i < *pnb; i++) b[i] = a[b[i]];
    for (i = 0; i < *pnc; i++) c[i] = a[c[i]];
    return 1;
  }
  b[0] = 0;
  b[1] = 2;
  c[0] = 1;
  *pnb = 2;
  *pnc = 1;
  if (try_add(a, na, b, pnb, c, pnc)) {
    int i;
    for (i = 0; i < *pnb; i++) b[i] = a[b[i]];
    for (i = 0; i < *pnc; i++) c[i] = a[c[i]];
    return 1;
  }
  c[0] = 0;
  b[0] = 1;
  b[1] = 2;
  *pnc = 1;
  *pnb = 2;
  if (try_add(a, na, b, pnb, c, pnc)) {
    int i;
    for (i = 0; i < *pnb; i++) b[i] = a[b[i]];
    for (i = 0; i < *pnc; i++) c[i] = a[c[i]];
    return 1;
  }
  return 0;
}