#include <bits/stdc++.h>
using namespace std;
int N;
int a[30005];
vector<int> p[2];
bool place(int index, int which) {
  if (index == N) return true;
  if (p[which].size() >= 2 &&
      p[which][1] - p[which][0] != a[index] - p[which].back())
    return false;
  p[which].push_back(a[index]);
  if (place(index + 1, 0) || place(index + 1, 1)) return true;
  p[which].pop_back();
  return false;
}
bool initial(int a1, int a2, int b1) {
  p[0].clear();
  p[1].clear();
  p[0].push_back(a[a1]);
  p[0].push_back(a[a2]);
  if (b1 == 2) {
    int index;
    for (index = 2; index < N; index++)
      if (a[index] - p[0].back() == p[0][1] - p[0][0])
        p[0].push_back(a[index]);
      else
        break;
    return place(index, 1);
  } else {
    p[1].push_back(a[b1]);
    return place(3, 0) || place(3, 1);
  }
}
void print_solution() {
  if (p[0].size() > p[1].size()) swap(p[0], p[1]);
  if (p[0].size() == 0) {
    p[0].push_back(p[1].back());
    p[1].pop_back();
  }
  for (int i = 0; i < (int)p[0].size(); i++) printf("%d ", p[0][i]);
  printf("\n");
  for (int i = 0; i < (int)p[1].size(); i++) printf("%d ", p[1][i]);
  printf("\n");
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &a[i]);
  if (N == 2) {
    printf("%d\n%d\n", a[0], a[1]);
    return 0;
  }
  if (initial(0, 1, 2) || initial(0, 2, 1) || initial(1, 2, 0))
    print_solution();
  else
    puts("No solution");
  return 0;
}
