#include <bits/stdc++.h>
using namespace std;
int n, a[30001], b[30001];
int input() {
  cin >> n;
  for (int i = (int)(0); i <= (int)(n - 1); i++) cin >> a[i];
  return 0;
}
int findTerms(int i, int x1, int x2, int dx, int y1, int y2, int dy) {
  int d, rv;
  if (i == n) return 0;
  b[i] = 0;
  d = a[i] - a[x2];
  if (d == dx) {
    b[i] = 1;
    rv = findTerms(i + 1, x2, i, dx, y1, y2, dy);
    if (rv >= 0) return rv + 1;
    b[i] = 0;
    if (rv == -2) return rv;
  }
  if (y1 > 0 && dy != (a[i] - a[y2])) return -1;
  if (y1 <= 0 && y2 > 0) dy = a[i] - a[y2];
  rv = findTerms(i + 1, x1, x2, dx, y2, i, dy);
  if (rv < 0) rv = -2;
  return rv;
}
int solve() {
  int y0, y1, y2, d1, d2, sec, rv;
  for (sec = 0; sec < n; sec++) {
    b[0] = b[sec] = 1;
    d1 = a[sec] - a[0];
    y2 = sec - 1;
    y1 = sec - 2;
    y0 = sec - 3;
    if (y1 > 0 && y2 > 0) d2 = a[y2] - a[y1];
    if (y0 > 0 && (a[y1] - a[y0]) != d2) {
      sec = n;
      break;
    }
    rv = findTerms(sec + 1, 0, sec, d1, y1, y2, d2);
    if (rv >= 0) break;
    b[0] = b[sec] = 0;
  }
  if (sec == n) {
    cout << "No solution\n";
  } else {
    for (int i = (int)(0); i <= (int)(n - 1); i++)
      if (b[i]) cout << a[i] << " ";
    cout << endl;
    for (int i = (int)(0); i <= (int)(n - 1); i++)
      if (!b[i]) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
int main() {
  input();
  solve();
  return 0;
}
