#include <bits/stdc++.h>
using namespace std;
const int maxn = 30010, INF = 1000000000;
int n, m, x, y;
int a[maxn], p[maxn], q[maxn];
set<int> u[maxn], v[maxn];
bool dfs(int now) {
  if (now == n) {
    if (x == 0 || y == 0) return false;
    for (int i = 0; i < x; i++) printf("%d ", p[i]);
    printf("\n");
    for (int i = 0; i < y; i++) printf("%d ", q[i]);
    printf("\n");
    return true;
  }
  if (x < 2 ||
      (a[now] - p[x - 1] == p[1] - p[0] && !u[now].count(p[1] - p[0]))) {
    if (x > 1) u[now].insert(p[1] - p[0]);
    p[x++] = a[now];
    if (dfs(now + 1)) return true;
    x--;
  }
  if (y < 2 ||
      (a[now] - q[y - 1] == q[1] - q[0] && !v[now].count(q[1] - q[0]))) {
    if (y > 1) v[now].insert(q[1] - q[0]);
    q[y++] = a[now];
    if (dfs(now + 1)) return true;
    y--;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  if (!dfs(0)) cout << "No solution" << endl;
  return 0;
}
