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;
struct tri {
  long long valor, acm;
  int vi;
};
struct par {
  int valor, id, acm;
  par(int valor = 0, int id = 0, int acm = 0)
      : valor(valor), id(id), acm(acm) {}
  bool operator<(const par &a) const {
    if (valor != a.valor) return valor < a.valor;
    return id < a.id;
  }
};
const double pi = acos(-1.0);
const double EPS = 1e-15;
const double INF = 1e50;
int cmp(double a, double b = 0.0) {
  if (fabs(a - b) < EPS) return 0;
  return a > b ? 1 : -1;
}
bool read(unsigned int &n) {
  n = 0;
  register bool neg = false;
  register char c = getchar_unlocked();
  if (c == EOF) {
    n = -1;
    return false;
  }
  while (!('0' <= c && c <= '9')) {
    if (c == '-') neg = true;
    c = getchar_unlocked();
  }
  while ('0' <= c && c <= '9') {
    n = n * 10 + c - '0';
    c = getchar_unlocked();
  }
  n = (neg ? (-n) : (n));
  return true;
}
vector<int> vet, v1, v2;
void printAns() {
  for (int i = 0; i < v1.size(); ++i) {
    if (i) cout << " ";
    cout << v1[i];
  }
  cout << "\n";
  for (int i = 0; i < v2.size(); ++i) {
    if (i) cout << " ";
    cout << v2[i];
  }
  cout << "\n";
}
int n, v;
bool solve(int k) {
  int r1 = 0, r2 = 0;
  if (v1.size() > 1) r1 = v1[1] - v1[0];
  if (v2.size() > 1) r2 = v2[1] - v2[0];
  for (int i = k; i <= n - 1; ++i) {
    if (v1.size() > 1 && v2.size() > 1 && (v1.back() + r1) == vet[i] &&
        (v2.back() + r2) == vet[i]) {
      if (i + 1 == n)
        v1.push_back(vet[i]);
      else {
        if (vet[i] + r1 == vet[i + 1])
          v1.push_back(vet[i]);
        else if (vet[i] + r2 == vet[i + 1])
          v2.push_back(vet[i]);
      }
    } else if (v1.size() > 1 && (v1.back() + r1) == vet[i])
      v1.push_back(vet[i]);
    else if (v2.size() > 1 && (v2.back() + r2) == vet[i])
      v2.push_back(vet[i]);
    else if (v1.size() <= 1) {
      v1.push_back(vet[i]);
      if (v1.size() > 1) r1 = v1[1] - v1[0];
    } else if (v2.size() <= 1) {
      v2.push_back(vet[i]);
      if (v2.size() > 1) r2 = v2[1] - v2[0];
    } else if (v1.size() && v2.size())
      return false;
  }
  if (!v1.size()) {
    v1.push_back(v2.back());
    v2.pop_back();
  } else if (!v2.size()) {
    v2.push_back(v1.back());
    v1.pop_back();
  }
  return ((v1.size() + v2.size()) == n);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> v;
    vet.push_back(v);
  }
  if (n == 2) {
    cout << vet[0] << "\n" << vet[1] << "\n";
    return 0;
  }
  if (n == 3) {
    cout << vet[0] << " " << vet[1] << "\n" << vet[2] << "\n";
    return 0;
  } else {
    for (int a = 0; a < 4; ++a) {
      for (int b = 0; b < 4; ++b) {
        if (b == a) continue;
        for (int c = 0; c < 4; ++c) {
          if (c == a || c == b) continue;
          for (int d = 0; d < 4; ++d) {
            if (d == a || d == b || d == c) continue;
            if (a < b && c < d) {
              v1.push_back(vet[a]);
              v1.push_back(vet[b]);
              v2.push_back(vet[c]);
              v2.push_back(vet[d]);
              if (solve(4)) {
                printAns();
                return 0;
              }
              v1.clear();
              v2.clear();
            }
            if (a < b && b < c && c < d) {
              v1.push_back(vet[a]);
              v1.push_back(vet[b]);
              v1.push_back(vet[c]);
              v1.push_back(vet[d]);
              int r = v1[1] - v1[0];
              if (v1[1] + r == v1[2] && v1[2] + r == v1[3])
                if (solve(4)) {
                  printAns();
                  return 0;
                }
              v1.clear();
              v2.clear();
            }
            if (a < b && b < c) {
              v1.push_back(vet[a]);
              v1.push_back(vet[b]);
              v1.push_back(vet[c]);
              v2.push_back(vet[d]);
              int r = v1[1] - v1[0];
              if (v1[1] + r == v1[2])
                if (solve(4)) {
                  printAns();
                  return 0;
                }
              v1.clear();
              v2.clear();
            }
            if (b < c && c < d) {
              v2.push_back(vet[a]);
              v1.push_back(vet[b]);
              v1.push_back(vet[c]);
              v1.push_back(vet[d]);
              int r = v1[1] - v1[0];
              if (v1[1] + r == v1[2])
                if (solve(4)) {
                  printAns();
                  return 0;
                }
              v1.clear();
              v2.clear();
            }
          }
        }
      }
    }
    if (n > 4) {
      v2.push_back(vet[0]);
      v2.push_back(vet[4]);
      v1.push_back(vet[1]);
      v1.push_back(vet[2]);
      v1.push_back(vet[3]);
      int r = v1[1] - v1[0];
      if (v1[1] + r == v1[2])
        if (solve(5)) {
          printAns();
          return 0;
        }
      v1.clear();
      v2.clear();
      v2.push_back(vet[0]);
      v2.push_back(vet[1]);
      v1.push_back(vet[2]);
      v1.push_back(vet[3]);
      v1.push_back(vet[4]);
      r = v1[1] - v1[0];
      if (v1[1] + r == v1[2])
        if (solve(5)) {
          printAns();
          return 0;
        }
      v1.clear();
      v2.clear();
      v2.push_back(vet[0]);
      v2.push_back(vet[1]);
      v2.push_back(vet[2]);
      v1.push_back(vet[3]);
      v1.push_back(vet[4]);
      r = v2[1] - v2[0];
      if (v2[1] + r == v2[2])
        if (solve(5)) {
          printAns();
          return 0;
        }
      v1.clear();
      v2.clear();
    }
  }
  cout << "No solution\n";
  return 0;
}