#include <bits/stdc++.h>
using namespace std;
int N;
int num[100005];
bool checar[100005];
bool lol() {
  int D = -num[N - 1] + num[N - 2];
  checar[N - 1] = checar[N - 2] = false;
  int ant = N - 2;
  bool chosto = false;
  int cont = 2;
  for (int i = ant - 1; i >= 0; i--) {
    if (!checar[i] && D != num[i] - num[ant]) return false;
    if (!checar[i]) {
      cont++;
      ant = i;
    }
    if (checar[i] && D == num[i] - num[ant] && chosto) return false;
    if (checar[i] && D == num[i] - num[ant]) checar[i] = false, cont++, ant = i;
    if (checar[i] && D != num[i] - num[ant]) chosto = true;
  }
  if (cont == N) checar[0] = true;
  return true;
}
bool Casos() {
  checar[0] = checar[1] = true;
  int ant = 1;
  int D = num[1] - num[0];
  int cont = 2;
  bool chosto = false;
  for (int i = 2; i < N; i++) {
    if (D == num[i] - num[ant]) {
      checar[i] = true;
      ant = i;
      cont++;
    }
  }
  if (cont == N) {
    checar[0] = false;
    return true;
  }
  if (cont == N - 1) return true;
  cont = 0;
  ant = 0;
  for (int i = 0; i < N && cont < 2; i++) {
    if (!checar[i]) {
      cont++;
      D = num[i] - num[ant];
      ant = i;
    }
  }
  for (int i = ant + 1; i < N; i++) {
    if (!checar[i]) {
      if (D != num[i] - num[ant]) {
        chosto = true;
        break;
      } else {
        ant = i;
      }
    }
  }
  if (!chosto) return true;
  if (lol()) return true;
  for (int i = 0; i < N; i++) checar[i] = false;
  checar[0] = checar[2] = true;
  ant = 2;
  D = num[2] - num[0];
  cont = 2;
  chosto = false;
  for (int i = 3; i < N; i++) {
    if (D == num[i] - num[ant]) {
      checar[i] = true;
      ant = i;
      cont++;
    }
  }
  if (cont == N - 1) return true;
  cont = 0;
  ant = 0;
  for (int i = 0; i < N && cont < 2; i++) {
    if (!checar[i]) {
      cont++;
      D = num[i] - num[ant];
      ant = i;
    }
  }
  for (int i = ant + 1; i < N; i++) {
    if (!checar[i]) {
      if (D != num[i] - num[ant]) {
        chosto = true;
        break;
      } else {
        ant = i;
      }
    }
  }
  if (!chosto) return true;
  if (lol()) return true;
  for (int i = 0; i < N; i++) checar[i] = false;
  checar[2] = checar[1] = true;
  ant = 2;
  D = num[2] - num[1];
  cont = 2;
  chosto = false;
  for (int i = 3; i < N; i++) {
    if (D == num[i] - num[ant]) {
      checar[i] = true;
      ant = i;
      cont++;
    }
  }
  if (cont == N - 1) return true;
  cont = 0;
  ant = 0;
  for (int i = 0; i < N && cont < 2; i++) {
    if (!checar[i]) {
      cont++;
      D = num[i] - num[ant];
      ant = i;
    }
  }
  for (int i = ant + 1; i < N; i++) {
    if (!checar[i]) {
      if (D != num[i] - num[ant]) {
        chosto = true;
        break;
      } else {
        ant = i;
      }
    }
  }
  if (!chosto) return true;
  if (lol()) return true;
  return false;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &num[i]);
  if (Casos()) {
    for (int i = 0; i < N; i++)
      if (checar[i]) printf("%d ", num[i]);
    printf("\n");
    for (int i = 0; i < N; i++)
      if (!checar[i]) printf("%d ", num[i]);
  } else
    printf("No solution\n");
  return 0;
}
