#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e6 + 7;
const int INF = 1e9;
const long long LINF = 1e18;
const int WOW = 40000;
const int NIL = 0;
const int dy[8] = {0, 0, -1, 1, 1, 1, -1, -1};
const int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
const double PI = 2 * acos(0);
const int MAXN = 30005;
int N;
int arr[MAXN];
bool vi[MAXN];
void print() {
  vector<int> a, b;
  for (int i = 0; i < N; ++i)
    if (vi[i])
      a.push_back(arr[i]);
    else
      b.push_back(arr[i]);
  if (!b.size()) {
    b.push_back(a.back());
    a.pop_back();
  }
  for (int v : a) printf("%d ", v);
  puts("");
  for (int v : b) printf("%d ", v);
  puts("");
  exit(0);
}
bool go2() {
  int a = INF, b = INF, last;
  for (int i = 0; i < N; ++i) {
    if (vi[i]) continue;
    if (a == INF) {
      a = arr[i];
      continue;
    }
    if (b == INF) {
      b = arr[i];
      last = b;
      continue;
    }
    if (arr[i] - last != b - a) return 0;
    last = arr[i];
  }
  return 1;
}
void go(int a, int b) {
  memset(vi, 0, sizeof(vi));
  vi[a] = vi[b] = 1;
  int nxt = arr[b] * 2 - arr[a];
  int last = b;
  for (int i = b + 1; i < N; ++i)
    if (arr[i] == nxt) nxt += arr[b] - arr[a], last = i, vi[i] = 1;
  if (go2()) print();
  vi[last] = 0;
  if (go2()) print();
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d", &arr[i]);
  if (N == 2) {
    printf("%d\n%d\n", arr[0], arr[1]);
    return 0;
  }
  go(0, 1);
  go(0, 2);
  go(1, 2);
  puts("No solution");
}
