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 inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = int(3e4) + 100;
const int MAX = int(1e8);
int n;
set<int> poss;
multiset<int> diffs;
int a[N];
int pref[N], suff[N];
map<int, int> pos;
inline void del_pos(int pos) {
  set<int>::iterator it = poss.find(pos);
  assert(it != poss.end());
  assert(*it == pos);
  set<int>::iterator _next = it;
  ++_next;
  if (it != poss.begin()) {
    set<int>::iterator _prev = it;
    --_prev;
    diffs.erase(diffs.find(a[pos] - a[*_prev]));
    if (_next != poss.end()) {
      diffs.erase(diffs.find(a[*_next] - a[pos]));
      diffs.insert(a[*_next] - a[*_prev]);
    }
  } else {
    if (_next != poss.end()) {
      diffs.erase(diffs.find(a[*_next] - a[pos]));
    }
  }
  poss.erase(it);
}
inline void print() {
  for (int i = 0; i < n; ++i) {
    if (poss.find(i) == poss.end()) {
      printf("%d ", a[i]);
    }
  }
  puts("");
  for (int i = 0; i < n; ++i) {
    if (poss.find(i) != poss.end()) {
      printf("%d ", a[i]);
    }
  }
  puts("");
  exit(0);
}
inline void solve1(int pos) {
  if (pos > 0 && pref[pos - 1] == -1) {
    return;
  }
  if (pos + 1 < n && suff[pos + 1] == -1) {
    return;
  }
  poss.clear();
  poss.insert(pos);
  if (pos == 0) {
    if (suff[pos + 1] != -1) {
      print();
    }
    return;
  }
  if (pos == n - 1) {
    if (pref[pos - 1] != -1) {
      print();
    }
    return;
  }
  if (pref[pos - 1] == -42 && suff[pos + 1] == -42) {
    print();
  }
  if (pref[pos - 1] == -42) {
    if (a[pos + 1] - a[pos - 1] == suff[pos + 1]) {
      print();
    }
    return;
  }
  if (suff[pos + 1] == -42) {
    if (a[pos + 1] - a[pos - 1] == pref[pos - 1]) {
      print();
    }
    return;
  }
  if (pref[pos - 1] == suff[pos + 1] &&
      a[pos + 1] - a[pos - 1] == pref[pos - 1]) {
    print();
  }
}
inline void check() {
  if (((int)(poss).size()) == 0) {
    return;
  }
  if (((int)(poss).size()) == 1) {
    print();
  }
  if (*diffs.begin() == *diffs.rbegin()) {
    print();
  }
}
inline void solve2(int p1, int p2) {
  poss.clear();
  diffs.clear();
  for (int i = 0; i < n; ++i) {
    poss.insert(i);
    if (i + 1 < n) {
      diffs.insert(a[i + 1] - a[i]);
    }
  }
  del_pos(p1);
  del_pos(p2);
  int cur = p2 + 1;
  int d = a[p2] - a[p1];
  check();
  for (;;) {
    int val = a[cur - 1] + d;
    if (abs(val) > MAX) {
      break;
    }
    int _next = pos[val];
    if (_next <= cur) {
      break;
    }
    cur = _next;
    del_pos(cur - 1);
    check();
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    pos[a[i]] = i + 1;
  }
  pref[0] = -42;
  pref[1] = a[1] - a[0];
  for (int i = 2; i < n; ++i) {
    if (a[i] - a[i - 1] == pref[i - 1]) {
      pref[i] = pref[i - 1];
    } else {
      pref[i] = -1;
    }
  }
  suff[n - 1] = -42;
  suff[n - 2] = a[n - 1] - a[n - 2];
  for (int i = n - 3; i >= 0; --i) {
    if (a[i + 1] - a[i] == suff[i + 1]) {
      suff[i] = suff[i + 1];
    } else {
      suff[i] = -1;
    }
  }
  for (int i = 0; i < n; ++i) {
    solve1(i);
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = i + 1; j < 3; ++j) {
      solve2(i, j);
    }
  }
  puts("No solution");
  return 0;
}