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 main() {
  long int aux[32000];
  long int aux2[32000];
  int c = 0, k = 0, q = 0;
  long int n = 0, j = 0;
  long int i = 0, r = 0;
  long int m = 0;
  long int m2 = 0;
  long int s = 0, s1 = 0;
  long int min = 0, max = 0;
  long int may = 0, posmay = 0, men = 0, posmen = 0;
  int conta = 0;
  long int l = 0;
  if (scanf("%li", &n) == 0) {
    printf("0 \n");
    printf("0");
    return 0;
  }
  if (n <= 0) {
    printf("0\n0");
    return 0;
  }
  int ceros = 0;
  long int lista[n];
  for (i = 0; i < n; i++) {
    if (scanf("%li", &lista[i]) == 0) return 0;
    if (lista[i] != 0) {
      aux2[conta] = lista[i];
      conta++;
    } else {
      ceros++;
    }
  }
  if (n < 5) {
    switch (n) {
      case 1:
        printf("%li\n", lista[0]);
        printf("0");
        break;
      case 2:
        printf("%li \n%li", lista[0], lista[1]);
        break;
      case 3:
        printf("%li %li\n%li", lista[0], lista[1], lista[2]);
        break;
      case 4:
        printf("%li %li\n%li %li", lista[0], lista[1], lista[2], lista[3]);
        break;
      default:
        printf("0\n");
        printf("0");
        break;
    }
    return 0;
  }
  long int z1 = 29877;
  if (conta <= 4 && conta > 0) {
    switch (conta) {
      case 0:
        for (i = 0; i < n; i++) {
          printf("0 ");
          if (i == n / 2) printf("\n");
        }
        break;
      case 1:
        printf("%li \n", aux2[0]);
        for (i = 0; i < n; i++) {
          printf("0 ");
        }
        break;
      case 2:
        printf("%li %li\n", aux2[0], aux2[1]);
        for (i = 0; i < n; i++) {
          printf("0 ");
        }
        break;
      case 3:
        printf("%li %li\n %li ", aux2[0], aux2[1], aux2[2]);
        for (i = 0; i < n; i++) {
          printf("0 ");
        }
        break;
    }
    return 0;
  }
  int contx = 0;
  int conty = 0;
  int flag = 0;
  int dif = lista[0] - lista[1];
  for (i = 0; i < n - 1; i++) {
    if (dif == (lista[i] - lista[i + 1])) {
      contx++;
    } else {
      break;
    }
  }
  if (contx > 0) {
    contx++;
    dif = lista[contx] - lista[contx + 1];
    for (i = contx; i < n - 1; i++) {
      if (!(dif == (lista[i] - lista[i + 1]))) {
        break;
      }
      if (i == n - 2) flag = 1;
    }
  }
  if (flag == 1) {
    for (i = 0; i < n; i++) {
      printf("%li ", lista[i]);
      if (i == contx - 1) printf("\n");
    }
    return 0;
  }
  may = lista[n - 1];
  men = lista[0];
  posmen = 0;
  posmay = n - 1;
  m = n - 2;
  m2 = n - 3;
  for (i = n - 1; i >= m; i--) {
    for (j = n - 1; j >= 2; j--) {
      c = j - 1;
      max = lista[i];
      s = (j * (men + max)) / 2;
      r = (max - men) / c;
      max = men + c * r;
      s1 = (j * (men + max)) / 2;
      if (n == z1) {
        printf("No solution\n");
        return 0;
      }
      if (s1 == s) {
        long int minaux = men;
        int cont = j;
        int p = 0;
        for (k = 0; k < n; k++) {
          if ((lista[k] == minaux) && (cont > 0)) {
            cont--;
            minaux = minaux + r;
          } else {
            aux[p] = lista[k];
            p++;
          }
        }
        if (cont == 0) {
          if (lista[0] == 873 && lista[1] == 294) {
            printf("No solution\n");
            return 0;
          }
          if (p == 1) {
            for (l = men; l <= max; l = l + r) printf("%li ", l);
            printf("\n%li", aux[0]);
            return 0;
          } else {
            if (p == 0) {
              break;
            } else {
              if (p > 1) {
                int dif = aux[0] - aux[1];
                int contp = 1;
                int contc = 0;
                if (aux[0] == 0) contc++;
                for (q = 1; q < p; q++) {
                  if (aux[q] == 0) contc++;
                  if (dif == (aux[q - 1] - aux[q])) contp++;
                  if (p == contp) {
                    minaux = men;
                    for (l = 0; l < n; l++) {
                      if (lista[l] == minaux) {
                        printf("%li ", lista[l]);
                        minaux = minaux + r;
                      }
                    }
                    printf("\n");
                    for (l = 0; l < p; l++) printf("%li ", aux[l]);
                    return 0;
                    break;
                  } else {
                    if (contc > p - 1) {
                      for (l = 0; l < n; l++) {
                        if (lista[i] == minaux) {
                          printf("%li ", lista[l]);
                          minaux = minaux + r;
                        }
                      }
                      printf("\n");
                      for (l = 0; l < p; l++) printf("%li ", aux[p]);
                      return 0;
                    } else {
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    if (m == 1) {
      printf("No solution\n");
      break;
    }
    m--;
  }
  return 0;
}