#include <bits/stdc++.h>
using namespace std;
const int Max = 30010;
int N, A[Max], C[Max], D[Max];
char U[Max];
map<int, int> ms;
map<int, int> value;
inline void remove(int d) {
  if (--ms[d] == 0) ms.erase(d);
}
bool check(int d, set<int> &lt) {
  int c = A[0] + d;
  int dn = 0;
  while (1) {
    int x = value[c];
    if (x == 0 || x < D[dn]) {
      for (int i = dn; i >= 1; i--) {
        x = D[i];
        pair<set<int>::iterator, bool> sb = lt.insert(x);
        set<int>::iterator p = sb.first;
        set<int>::iterator s = p, t = p;
        --s, ++t;
        if (p != lt.begin() && t != lt.end()) remove(A[*t] - A[*s]);
        if (t != lt.end()) ++ms[A[*t] - A[x]];
        if (p != lt.begin()) ++ms[A[x] - A[*s]];
        U[x] = 0;
      }
      return false;
    }
    D[++dn] = --x;
    set<int>::iterator p = lt.find(x);
    set<int>::iterator s = p, t = p;
    --s, ++t;
    U[x] = 1;
    if (p != lt.begin()) remove(A[x] - A[*s]);
    if (t != lt.end()) remove(A[*t] - A[x]);
    if (p != lt.begin() && t != lt.end()) ++ms[A[*t] - A[*s]];
    lt.erase(x);
    if (1 == ms.size()) return true;
    c += d;
  }
}
void out() {
  int f = 0;
  for (int i = 0; i < N; i++)
    if (U[i] == 1) {
      if (f++) putchar(' ');
      printf("%d", A[i]);
    }
  putchar('\n');
  f = 0;
  for (int i = 0; i < N; i++)
    if (U[i] == 0) {
      if (f++) putchar(' ');
      printf("%d", A[i]);
    }
  putchar('\n');
}
int main() {
  for (int i = 0; i < Max; i++) C[i] = i;
  while (scanf("%d", &N) != EOF) {
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    if (N == 2) {
      printf("%d\n%d\n", A[0], A[1]);
      continue;
    }
    value.clear();
    for (int i = 0; i < N; i++) value[A[i]] = i + 1;
    ms.clear();
    for (int i = 2; i < N; i++) ++ms[A[i] - A[i - 1]];
    memset(U, 0, sizeof(U[0]) * N);
    U[0] = 1;
    if (1 == ms.size()) {
      out();
      continue;
    }
    set<int> lt(C + 1, C + N);
    bool find = false;
    for (int i = 1; i < N; i++)
      if (check(A[i] - A[0], lt)) {
        find = true;
        out();
        break;
      }
    if (!find) puts("No solution");
  }
  return 0;
}
