#include <bits/stdc++.h>
int n, flag, a[30010], b[30010], tot, u[30010];
void orzbgg() {
  for (int i = 1; i <= n; ++i)
    if (u[i]) printf("%d ", a[i]);
  printf("\n");
  for (int i = 1; i <= n; ++i)
    if (!u[i]) printf("%d ", a[i]);
  printf("\n");
  exit(0);
}
bool bggjq() {
  tot = 0;
  int d, nxt;
  for (int i = 1; i <= n; ++i)
    if (!u[i]) b[++tot] = a[i];
  if (tot == 0) return 0;
  if (tot < 3) return 1;
  d = b[2] - b[1];
  nxt = b[1];
  for (int i = 1; i <= tot; ++i) {
    if (b[i] != nxt) return 0;
    nxt += d;
  }
  return 1;
}
void check(int x, int y) {
  memset(u, 0, sizeof(u));
  int d = y - x, nxt;
  nxt = x;
  for (int i = 1; i <= n; ++i)
    if (a[i] == nxt) {
      u[i] = 1;
      nxt += d;
    }
  if (bggjq()) orzbgg();
  nxt = n;
  while (u[nxt] == 0) --nxt;
  u[nxt] = 0;
  if (bggjq()) orzbgg();
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  check(a[1], a[2]);
  check(a[1], a[3]);
  check(a[2], a[3]);
  printf("No solution\n");
  return 0;
}
