#include <bits/stdc++.h>
int a[30003], v[30003], n;
int check(int x, int y) {
  int b[30003], i, j, ok, d = a[y] - a[x], num = 2;
  for (i = 1; i <= n; i++) v[i] = 0;
  v[x] = 1, v[y] = 1;
  for (j = a[y], i = y + 1; i <= n; i++)
    if (j + d == a[i]) v[i] = 1, j = a[i], num++;
  for (j = 0, i = 1; i <= n; i++)
    if (!v[i]) b[j++] = a[i];
  if (num == n) v[n] = 0, b[j++] = a[n];
  if (j <= 2) return 1;
  for (ok = 1, d = b[1] - b[0], i = 2; i < j; i++)
    if (b[i] - b[i - 1] != d) ok = 0;
  if (ok) return 1;
  for (i = n; i >= 1; i--)
    if (v[i]) break;
  v[i] = 0;
  for (j = 0, i = 1; i <= n; i++)
    if (!v[i]) b[j++] = a[i];
  for (d = b[1] - b[0], i = 2; i < j; i++)
    if (b[i] - b[i - 1] != d) return 0;
  return 1;
}
void print() {
  int i;
  for (i = 1; i <= n; i++)
    if (v[i]) printf("%d ", a[i]);
  printf("\n");
  for (i = 1; i <= n; i++)
    if (!v[i]) printf("%d ", a[i]);
  printf("\n");
}
int main() {
  int i;
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    if (n == 2) {
      printf("%d\n%d\n", a[1], a[2]);
      continue;
    }
    if (check(1, 2)) {
      print();
      continue;
    }
    if (check(1, 3)) {
      print();
      continue;
    }
    if (check(2, 3)) {
      print();
      continue;
    }
    printf("No solution\n");
  }
  return 0;
}
