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;
bool check(vector<int>& v, vector<int> a, int n) {
  int i = 0, j = 0;
  while (i < n && v[i] == 1000000007) {
    i++;
  }
  if (i == n) {
    v[n - 1] = a[n - 1];
    return true;
  }
  j = i + 1;
  while (j < n && v[j] == 1000000007) {
    j++;
  }
  if (j == n) {
    return true;
  }
  int d = v[j] - v[i];
  int ti = i, tj = j;
  i = j;
  j = i + 1;
  int f = 0;
  while (j < n) {
    while (j < n && v[j] == 1000000007) j++;
    if (j == n) return true;
    if (v[j] - v[i] != d) {
      if (v[j] - v[i] != 2 * d) {
        f = 1;
        j = n;
        break;
      }
      int k = i + 1;
      while (k < j) {
        if (a[k] - v[i] == d) {
          v[k] = a[k];
          break;
        }
        k++;
      }
    }
    i = j;
    j++;
  }
  i = ti;
  j = tj;
  if (f) {
    if (d % 2) return false;
    int k = i + 1;
    while (k < j) {
      if (a[k] - v[i] == d / 2) {
        v[k] = a[k];
        f = 2;
        break;
      }
      k++;
    }
    if (f != 2) {
      return false;
    }
    d = d / 2;
    i = j;
    j++;
    while (j < n) {
      while (j < n && v[j] == 1000000007) j++;
      if (j == n) return true;
      if (v[j] - v[i] != d) {
        if (v[j] - v[i] != 2 * d) {
          return false;
        }
        int k = i + 1;
        while (k < j) {
          if (a[k] - v[i] == d) {
            v[k] = a[k];
            break;
          }
          k++;
        }
      }
      i = j;
      j++;
    }
  }
  return true;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), t1(n), t2(n), t3(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    t1[i] = a[i];
    t2[i] = a[i];
    t3[i] = a[i];
  }
  if (n == 2) {
    cout << a[0] << '\n';
    cout << a[1] << '\n';
    return;
  }
  if (n == 3) {
    cout << a[0] << " " << a[1] << '\n';
    cout << a[2] << '\n';
    return;
  }
  if (n == 4) {
    cout << a[0] << " " << a[1] << '\n';
    cout << a[2] << " " << a[3] << '\n';
    return;
  }
  int d = a[1] - a[0];
  t1[0] = 1000000007, t1[1] = 1000000007;
  int i = 1, j = 2;
  while (j < n) {
    while (j < n && a[j] - a[i] != d) {
      j++;
    }
    if (j == n) break;
    t1[j] = 1000000007;
    i = j;
  }
  if (check(t1, a, n)) {
    for (int i = 0; i < n; i++) {
      if (t1[i] == 1000000007) cout << a[i] << " ";
    }
    cout << '\n';
    for (int i = 0; i < n; i++) {
      if (t1[i] != 1000000007) cout << t1[i] << " ";
    }
    cout << '\n';
    return;
  }
  d = a[2] - a[0];
  t2[0] = 1000000007, t2[2] = 1000000007;
  i = 2, j = 3;
  while (j < n) {
    while (j < n && a[j] - a[i] != d) {
      j++;
    }
    if (j == n) break;
    t2[j] = 1000000007;
    i = j;
  }
  if (check(t2, a, n)) {
    for (int i = 0; i < n; i++) {
      if (t2[i] == 1000000007) cout << a[i] << " ";
    }
    cout << '\n';
    for (int i = 0; i < n; i++) {
      if (t2[i] != 1000000007) cout << t2[i] << " ";
    }
    cout << '\n';
    return;
  }
  d = a[2] - a[1];
  t3[1] = 1000000007, t3[2] = 1000000007;
  i = 2, j = 3;
  while (j < n) {
    while (j < n && a[j] - a[i] != d) {
      j++;
    }
    if (j == n) break;
    t3[j] = 1000000007;
    i = j;
  }
  if (check(t3, a, n)) {
    for (int i = 0; i < n; i++) {
      if (t3[i] == 1000000007) cout << a[i] << " ";
    }
    cout << '\n';
    for (int i = 0; i < n; i++) {
      if (t3[i] != 1000000007) cout << t3[i] << " ";
    }
    cout << '\n';
    return;
  }
  cout << "No solution";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}