#include <bits/stdc++.h>
using namespace std;
bool check2(const vector<int>& B, vector<int>& R1, vector<int>& R2) {
  if (int((R2).size()) <= 2) return true;
  int n1 = int((R1).size());
  vector<int> T = {R2[0], R2[1]};
  const int d2 = R2[1] - R2[0];
  for (int i = 2; i < int((R2).size());) {
    if (R2[i] != T.back() + d2) {
      if (n1 == 0 || R1[n1 - 1] != T.back() + d2) return false;
      T.push_back(R1.back());
      --n1;
    } else {
      T.push_back(R2[i]);
      ++i;
    }
  }
  swap(R2, T);
  R1.resize(n1);
  return true;
}
bool trace;
bool check1(int from, const vector<int>& B, vector<int>& R1, vector<int>& R2) {
  assert(int((R1).size()) >= 2);
  const int d1 = R1[1] - R1[0];
  for (int i = from; i < int((B).size()); ++i) {
    int x = B[i];
    if (R1.back() + d1 == x)
      R1.push_back(x);
    else
      R2.push_back(x);
  }
  if (trace) {
    cerr << "R1: ";
    for (int x : R1) cerr << x << ' ';
    cerr << endl;
    cerr << "R2: ";
    for (int x : R2) cerr << x << ' ';
    cerr << endl;
  }
  if (!check2(B, R1, R2)) {
    R2.insert(R2.begin() + 1, R1.back());
    R1.pop_back();
    if (!check2(B, R1, R2)) return false;
  }
  return true;
}
void solve(vector<int> A) {
  int N = A.size();
  if (N <= 3) {
    cout << A[0] << endl;
    for (int i = (1), _b = (N - 1); i <= _b; ++i) cout << A[i] << ' ';
    cout << endl;
    return;
  }
  vector<int> R1, R2;
  R1 = {A[0], A[1]};
  R2 = {};
  if (!check1(2, A, R1, R2)) {
    R1 = {A[0], A[2]};
    R2 = {A[1]};
    if (!check1(3, A, R1, R2)) {
      R2 = {A[0]};
      R1 = {A[1], A[2]};
      if (!check1(3, A, R1, R2)) {
        cout << "No solution\n";
        return;
      }
    }
  }
  if (R2.empty()) {
    R2.push_back(R1.back());
    R1.pop_back();
  }
  for (int x : R1) cout << x << ' ';
  cout << endl;
  for (int x : R2) cout << x << ' ';
  cout << endl;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0, _n = (N); i < _n; ++i) cin >> A[i];
  solve(A);
  return 0;
}
