#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50000;
const int INF = 0x7FFFFFFF;
const double eps = 1e-10;
const double pi = acos(-1.0);
int n, tot1, tot2;
int a[MAXN], A[MAXN], B[MAXN], C[MAXN];
map<int, pair<int, int> > number;
void init() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
}
bool check(int x, int y) {
  number.clear();
  for (int i = 0; i < n; i++) number[a[i]] = make_pair(i, 1);
  tot1 = tot2 = 0;
  A[tot1++] = a[x];
  A[tot1++] = a[y];
  number[a[x]].second = 0;
  number[a[y]].second = 0;
  int delta = A[1] - A[0];
  int pre = number[a[y]].first;
  while (true) {
    int next = A[tot1 - 1] + delta;
    if (number[next].second == 0 || number[next].first < pre) break;
    --number[next].second;
    pre = number[next].first;
    A[tot1++] = next;
  }
  for (int i = 0; i < n; i++)
    if (number[a[i]].second > 0) B[tot2++] = a[i];
  bool flag = true;
  for (int i = 1; i < tot2 - 1; i++)
    if (abs(B[i] - B[i - 1]) != abs(B[i + 1] - B[i])) {
      flag = false;
      break;
    }
  if (flag) return true;
  number.clear();
  {
    number.clear();
    for (int i = 0; i < tot1; i++) number[A[i]] = make_pair(i, 1);
    int delta = INF;
    for (int i = 1; i < tot2; i++)
      if (abs(B[i] - B[i - 1]) < abs(delta)) delta = B[i] - B[i - 1];
    int now = B[0], tot3 = 1, tot4 = tot1, pre = -1, k = 1;
    C[0] = B[0];
    for (int i = 1;; i++) {
      now += delta;
      if (B[k] != now) {
        if (pre == tot4 - 1) break;
        if (number[now].second > 0) {
          if (number[now].first < pre) return false;
          if (pre == -1) tot1 = number[now].first;
          pre = number[now].first;
          C[tot3++] = now;
        } else
          return false;
      } else {
        C[tot3++] = B[k++];
      }
    }
    tot2 = tot3;
    if (tot1 + tot2 != n) return false;
    for (int i = 0; i < tot3; i++) B[i] = C[i];
    return true;
  }
  return true;
}
void solve() {
  bool flag = true;
  for (int i = 1; i < n - 1; i++)
    if (a[i] - a[i - 1] != a[i + 1] - a[i]) {
      flag = false;
      break;
    }
  if (flag) {
    cout << a[0] << endl;
    for (int i = 1; i < n; i++) {
      if (i > 1) cout << ' ';
      cout << a[i];
    }
    cout << endl;
    return;
  }
  flag = check(0, 1) || check(1, 2) || check(0, 2);
  if (!flag)
    cout << "No solution" << endl;
  else {
    for (int i = 0; i < tot1; i++) {
      if (i > 0) cout << ' ';
      cout << A[i];
    }
    cout << endl;
    for (int i = 0; i < tot2; i++) {
      if (i > 0) cout << ' ';
      cout << B[i];
    }
    cout << endl;
  }
}
int main() {
  init();
  solve();
  return 0;
}
