#include <bits/stdc++.h>
using namespace std;
const int maxn = 30005;
int a[maxn];
int b[maxn], c[maxn];
bool used[maxn];
int n, bn, cn;
void print() {
  for (int i = 1; i <= bn; i++) printf("%d ", b[i]);
  printf("\n");
  for (int i = 1; i <= cn; i++) printf("%d ", c[i]);
  printf("\n");
}
bool judgeC() {
  int i;
  int cd = c[2] - c[1];
  bool flag = true;
  i = 3;
  while (i <= cn) {
    if (c[i] - c[i - 1] != cd) {
      flag = false;
      break;
    }
    i++;
  }
  if (flag) return true;
  return false;
}
bool judgeB() {
  int i;
  int bd = b[2] - b[1];
  bool flag = true;
  i = 3;
  while (i <= bn) {
    if (b[i] - b[i - 1] != bd) {
      flag = false;
      break;
    }
    i++;
  }
  if (flag) return true;
  return false;
}
bool judge() {
  int i;
  used[1] = false;
  cn = 0;
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (judgeC()) {
    for (i = 2; i <= bn; i++) printf("%d ", b[i]);
    printf("\n");
    for (i = 1; i <= cn; i++) printf("%d ", c[i]);
    printf("\n");
    return true;
  }
  used[1] = true;
  int tmp = b[bn];
  for (i = 1; i <= n; i++)
    if (a[i] == tmp) break;
  used[i] = false;
  cn = 0;
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (judgeC()) {
    bn--;
    print();
    return true;
  }
  return false;
}
bool solve1() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  b[++bn] = a[1];
  used[1] = true;
  if (a[2] - a[1] == a[3] - a[2]) {
    b[++bn] = a[2];
    b[++bn] = a[3];
    used[2] = used[3] = true;
    int d = b[2] - b[1];
    i = 4;
    while (i <= n) {
      if (a[i] - b[bn] == d) {
        b[++bn] = a[i];
        used[i] = true;
      }
      i++;
    }
    for (i = 1; i <= n; i++)
      if (!used[i]) c[++cn] = a[i];
    if (cn == 0) {
      c[++cn] = b[bn];
      bn--;
      print();
      return true;
    } else if (cn == 1 || cn == 2) {
      print();
      return true;
    } else {
      if (judgeC()) {
        print();
        return true;
      } else if (judge())
        return true;
    }
  }
  return false;
}
bool solve2() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  c[++cn] = a[2];
  c[++cn] = a[3];
  used[2] = true;
  used[3] = true;
  int d = c[2] - c[1];
  i = 4;
  while (i <= n) {
    if (a[i] - c[cn] == d) {
      c[++cn] = a[i];
      used[i] = true;
    }
    i++;
  }
  for (i = 1; i <= n; i++)
    if (!used[i]) b[++bn] = a[i];
  if (bn == 1 || bn == 2) {
    print();
    return true;
  } else {
    if (judgeB()) {
      print();
      return true;
    } else {
      used[2] = false;
      bn = 0;
      for (i = 1; i <= n; i++)
        if (!used[i]) b[++bn] = a[i];
      if (judgeB()) {
        for (i = 1; i <= bn; i++) printf("%d ", b[i]);
        printf("\n");
        for (i = 2; i <= cn; i++) printf("%d ", c[i]);
        printf("\n");
        return true;
      }
      int tmp = c[cn];
      for (i = 1; i <= n; i++)
        if (tmp == a[i]) break;
      used[2] = true;
      used[i] = false;
      bn = 0;
      for (i = 1; i <= n; i++)
        if (!used[i]) b[++bn] = a[i];
      if (judgeB()) {
        cn--;
        print();
        return true;
      }
    }
  }
  return false;
}
bool solve3() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  b[++bn] = a[1];
  b[++bn] = a[2];
  used[1] = true;
  used[2] = true;
  int d = b[2] - b[1];
  i = 4;
  while (i <= n) {
    if (a[i] - b[bn] == d) {
      b[++bn] = a[i];
      used[i] = true;
    }
    i++;
  }
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (cn == 1 || cn == 2) {
    print();
    return true;
  } else {
    if (judgeC()) {
      print();
      return true;
    } else if (judge())
      return true;
  }
  return false;
}
bool solve4() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  b[++bn] = a[1];
  b[++bn] = a[3];
  used[1] = true;
  used[3] = true;
  int d = b[2] - b[1];
  i = 4;
  while (i <= n) {
    if (a[i] - b[bn] == d) {
      b[++bn] = a[i];
      used[i] = true;
    }
    i++;
  }
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (cn == 1 || cn == 2) {
    print();
    return true;
  } else {
    if (judgeC()) {
      print();
      return true;
    } else if (judge())
      return true;
  }
  return false;
}
int main() {
  int i;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    if (n == 2) {
      cout << a[1] << endl;
      cout << a[2] << endl;
      continue;
    } else if (n == 3) {
      cout << a[1] << " " << a[2] << endl;
      cout << a[3] << endl;
      continue;
    } else {
      if (solve1())
        continue;
      else if (solve2())
        continue;
      else if (solve3())
        continue;
      else if (solve4())
        continue;
      else
        cout << "No solution" << endl;
    }
  }
  return 0;
}
