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 main() {
  int n;
  int g;
  cin >> n;
  int* a = new int[n];
  int* b = new int[n];
  int x0;
  int x1;
  int d0;
  int d1;
  int m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  b[0] = 0;
  b[1] = 0;
  d0 = a[1] - a[0];
  x0 = a[1];
  m = 2;
  while ((m < n) && ((a[m] - x0) == d0)) {
    x0 = a[m];
    b[m] = 0;
    ++m;
  }
  if (m == n) {
    cout << a[0] << "\n" << a[1];
    for (int i = 2; i < n; ++i) cout << " " << a[i];
    cout << "\n";
    return 0;
  }
  b[m] = 1;
  x1 = a[m];
  g = 0;
  int tmp;
  g = 2;
  for (int j = -1; j < 2; ++j) {
    if (g == 2) {
      int i;
      if (j > -1) {
        d0 = a[2] - a[j];
        x1 = a[1 - j];
        x0 = a[2];
        b[0] = j;
        b[1] = 1 - j;
        b[2] = 0;
        i = 3;
      } else {
        i = m + 1;
      }
      g = 0;
      for (; i < n; ++i) {
        if ((a[i] - x0) == d0) {
          if (g == 0) {
            tmp = x1;
            d1 = a[i] - x1;
            x1 = a[i];
            b[i] = 1;
            for (int k = i + 1; k < n; ++k) {
              if ((a[k] - x1) == d1) {
                x1 = a[k];
                b[k] = 1;
              } else {
                g = 2;
                break;
              }
            }
            if (g == 2) {
              x1 = tmp;
              g = 0;
            } else
              break;
          }
          if (g && ((a[i] - x1) == d1)) {
            tmp = x0;
            x0 = a[i];
            b[i] = 0;
            for (int k = i + 1; k < n; ++k) {
              if ((a[k] - x0) == d0) {
                x0 = a[k];
                b[k] = 0;
              } else {
                g = 2;
                break;
              }
            }
            if (g == 2) {
              g = 0;
              x0 = tmp;
              x1 = a[i];
              b[i] = 1;
              for (int k = i + 1; k < n; ++k) {
                if ((a[k] - x1) == d1) {
                  x1 = a[k];
                  b[k] = 1;
                } else {
                  g = 2;
                  break;
                }
              }
            }
            break;
          } else {
            b[i] = 0;
            x0 = a[i];
          }
        } else if (g) {
          if ((a[i] - x1) == d1) {
            b[i] = 1;
            x1 = a[i];
          } else {
            g = 2;
            break;
          }
        } else {
          g = 1;
          b[i] = 1;
          d1 = a[i] - x1;
          x1 = a[i];
        }
      }
    }
  }
  if (g == 2)
    cout << "No solution\n";
  else {
    for (int i = 0; i < n; ++i) {
      if (b[i] == 0) {
        if (a[i] == x0)
          cout << x0;
        else
          cout << a[i] << " ";
      }
    }
    cout << "\n";
    for (int i = 0; i < n; ++i) {
      if (b[i] == 1) {
        if (a[i] == x1)
          cout << x1;
        else
          cout << a[i] << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}