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>
const int MOD = (int)1e9 + 7;
const double eps0 = 1e-6;
const double eps = 1e-9;
const long double eps2 = 1e-18;
using namespace std;
const int MAXN = 30010;
int diff[MAXN], num[MAXN];
int N, M;
int res1[MAXN], res2[MAXN];
int idx1, idx2, a1, a2, d1, d2, alen, blen;
bool try1() {
  alen = 2;
  blen = 0;
  res1[0] = 0;
  res1[1] = 1;
  idx1 = 1;
  d1 = num[1] - num[0];
  while (num[idx1 + 1] - num[idx1] == d1) {
    res1[alen++] = idx1 + 1;
    idx1++;
  }
  idx2 = idx1 + 1;
  res2[blen++] = idx2;
  int t = idx2 + 1;
  while (num[t] - num[idx1] == d1) {
    res1[alen++] = t;
    idx1 = t;
    t++;
  }
  d2 = num[t] - num[idx2];
  idx2 = t;
  res2[blen++] = idx2;
  t++;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      if (num[t - 1] - num[res1[alen - 2]] == d1 &&
          num[t - 1] - num[res2[blen - 1]] == d2) {
        alen--;
        idx1 = res1[alen - 1];
        res2[blen++] = t - 1;
        idx2 = t - 1;
        continue;
      } else {
        good = 0;
        break;
      }
    }
  }
  return good;
}
bool try2() {
  idx1 = 2;
  idx2 = 1;
  alen = 2;
  blen = 1;
  res1[0] = 0;
  res1[1] = 2;
  res2[0] = 1;
  d1 = num[2] - num[0];
  while (num[idx1 + 1] - num[idx1] == d1) {
    res1[alen++] = idx1 + 1;
    idx1++;
  }
  d2 = num[idx1 + 1] - num[1];
  idx2 = idx1 + 1;
  res2[blen++] = idx2;
  int t = idx2 + 1;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      if (num[t - 1] - num[res1[alen - 2]] == d1 &&
          num[t - 1] - num[res2[blen - 1]] == d2) {
        alen--;
        idx1 = res1[alen - 1];
        res2[blen++] = t - 1;
        idx2 = t - 1;
        continue;
      } else {
        good = 0;
        break;
      }
    }
  }
  return good;
}
bool try3() {
  alen = 1;
  blen = 2;
  d2 = num[2] - num[1];
  res2[0] = 1;
  res2[1] = 2;
  res1[0] = 0;
  idx2 = 2;
  while (num[idx2 + 1] - num[idx2] == d2) {
    res2[blen++] = idx2 + 1;
    idx2++;
  }
  idx1 = idx2 + 1;
  res1[alen++] = idx1;
  d1 = num[idx1] - num[0];
  int t = idx1 + 1;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      if (num[t - 1] - num[res1[alen - 2]] == d1 &&
          num[t - 1] - num[res2[blen - 1]] == d2) {
        alen--;
        idx1 = res1[alen - 1];
        res2[blen++] = t - 1;
        idx2 = t - 1;
        continue;
      } else {
        good = 0;
        break;
      }
    }
  }
  return good;
}
bool try4() {
  alen = 1;
  blen = 2;
  d2 = num[2] - num[1];
  res2[0] = 1;
  res2[1] = 2;
  res1[0] = 0;
  idx2 = 2;
  while (num[idx2 + 1] - num[idx2] == d2) {
    res2[blen++] = idx2 + 1;
    idx2++;
  }
  if (blen < 3) return 0;
  idx1 = idx2;
  idx2--;
  blen--;
  res1[alen++] = idx1;
  d1 = num[idx1] - num[0];
  int t = idx1 + 1;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      good = 0;
      break;
    }
  }
  return good;
}
void construct() {
  if (0) printf("alen:%d, blen:%d\n", alen, blen);
  for (int ii = 0; ii < alen; ii++) {
    if (ii != 0) printf(" ");
    printf("%d", num[res1[ii]]);
  }
  printf("\n");
  for (int ii = 0; ii < blen; ii++) {
    if (ii != 0) printf(" ");
    printf("%d", num[res2[ii]]);
  }
  printf("\n");
}
int main(void) {
  while (cin >> N) {
    for (int i = 0; i < (N); i++) scanf("%d", &num[i]);
    M = unique(diff + 1, adjacent_difference(num, num + N, diff)) - diff - 1;
    if (0) {
      cout << "M: " << M << endl;
      for (int i = 1; i <= (M); i++) cout << diff[i] << endl;
    }
    if (N == 2) {
      cout << num[0] << endl << num[1] << endl;
      continue;
    } else if (M == 1) {
      for (int i = 0; i < (N - 2); i++) printf("%d ", num[i]);
      printf("%d\n%d\n", num[N - 2], num[N - 1]);
    } else if (M == 2) {
      d1 = diff[1];
      d2 = diff[2];
      int t = 1;
      idx1 = 0;
      printf("%d", num[0]);
      while (num[t] - num[idx1] == d1) {
        printf(" %d", num[t]);
        idx1 = t;
        t++;
      }
      printf("\n");
      for (; t < N - 1; t++) printf("%d ", num[t]);
      printf("%d\n", num[t]);
    } else {
      if (try1()) {
        construct();
      } else if (try2()) {
        construct();
      } else if (try3()) {
        construct();
      } else if (try4()) {
        construct();
      } else {
        printf("No solution\n");
      }
    }
  }
}