#include <bits/stdc++.h>
const int MOD = (int)1e9 + 7;
const double eps0 = 1e-6;
const double eps = 1e-9;
const long double eps2 = 1e-18;
using namespace std;
const int MAXN = 30010;
int diff[MAXN], num[MAXN];
int N, M;
int res1[MAXN], res2[MAXN];
int idx1, idx2, a1, a2, d1, d2, alen, blen;
bool try1() {
  alen = 2;
  blen = 0;
  res1[0] = 0;
  res1[1] = 1;
  idx1 = 1;
  d1 = num[1] - num[0];
  while (num[idx1 + 1] - num[idx1] == d1) {
    res1[alen++] = idx1 + 1;
    idx1++;
  }
  idx2 = idx1 + 1;
  res2[blen++] = idx2;
  int t = idx2 + 1;
  while (num[t] - num[idx1] == d1) {
    res1[alen++] = t;
    idx1 = t;
    t++;
  }
  d2 = num[t] - num[idx2];
  idx2 = t;
  res2[blen++] = idx2;
  t++;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      if (num[t - 1] - num[res1[alen - 2]] == d1 &&
          num[t - 1] - num[res2[blen - 1]] == d2) {
        alen--;
        idx1 = res1[alen - 1];
        res2[blen++] = t - 1;
        idx2 = t - 1;
        continue;
      } else {
        good = 0;
        break;
      }
    }
  }
  return good;
}
bool try2() {
  idx1 = 2;
  idx2 = 1;
  alen = 2;
  blen = 1;
  res1[0] = 0;
  res1[1] = 2;
  res2[0] = 1;
  d1 = num[2] - num[0];
  while (num[idx1 + 1] - num[idx1] == d1) {
    res1[alen++] = idx1 + 1;
    idx1++;
  }
  d2 = num[idx1 + 1] - num[1];
  idx2 = idx1 + 1;
  res2[blen++] = idx2;
  int t = idx2 + 1;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      if (num[t - 1] - num[res1[alen - 2]] == d1 &&
          num[t - 1] - num[res2[blen - 1]] == d2) {
        alen--;
        idx1 = res1[alen - 1];
        res2[blen++] = t - 1;
        idx2 = t - 1;
        continue;
      } else {
        good = 0;
        break;
      }
    }
  }
  return good;
}
bool try3() {
  alen = 1;
  blen = 2;
  d2 = num[2] - num[1];
  res2[0] = 1;
  res2[1] = 2;
  res1[0] = 0;
  idx2 = 2;
  while (num[idx2 + 1] - num[idx2] == d2) {
    res2[blen++] = idx2 + 1;
    idx2++;
  }
  idx1 = idx2 + 1;
  res1[alen++] = idx1;
  d1 = num[idx1] - num[0];
  int t = idx1 + 1;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      if (num[t - 1] - num[res1[alen - 2]] == d1 &&
          num[t - 1] - num[res2[blen - 1]] == d2) {
        alen--;
        idx1 = res1[alen - 1];
        res2[blen++] = t - 1;
        idx2 = t - 1;
        continue;
      } else {
        good = 0;
        break;
      }
    }
  }
  return good;
}
bool try4() {
  alen = 1;
  blen = 2;
  d2 = num[2] - num[1];
  res2[0] = 1;
  res2[1] = 2;
  res1[0] = 0;
  idx2 = 2;
  while (num[idx2 + 1] - num[idx2] == d2) {
    res2[blen++] = idx2 + 1;
    idx2++;
  }
  if (blen < 3) return 0;
  idx1 = idx2;
  idx2--;
  blen--;
  res1[alen++] = idx1;
  d1 = num[idx1] - num[0];
  int t = idx1 + 1;
  bool good = 1;
  while (t < N) {
    int t1 = num[t] - num[idx1], t2 = num[t] - num[idx2];
    if (t1 == d1) {
      res1[alen++] = t;
      idx1 = t;
      t++;
    } else if (t2 == d2) {
      res2[blen++] = t;
      idx2 = t;
      t++;
    } else {
      good = 0;
      break;
    }
  }
  return good;
}
void construct() {
  if (0) printf("alen:%d, blen:%d\n", alen, blen);
  for (int ii = 0; ii < alen; ii++) {
    if (ii != 0) printf(" ");
    printf("%d", num[res1[ii]]);
  }
  printf("\n");
  for (int ii = 0; ii < blen; ii++) {
    if (ii != 0) printf(" ");
    printf("%d", num[res2[ii]]);
  }
  printf("\n");
}
int main(void) {
  while (cin >> N) {
    for (int i = 0; i < (N); i++) scanf("%d", &num[i]);
    M = unique(diff + 1, adjacent_difference(num, num + N, diff)) - diff - 1;
    if (0) {
      cout << "M: " << M << endl;
      for (int i = 1; i <= (M); i++) cout << diff[i] << endl;
    }
    if (N == 2) {
      cout << num[0] << endl << num[1] << endl;
      continue;
    } else if (M == 1) {
      for (int i = 0; i < (N - 2); i++) printf("%d ", num[i]);
      printf("%d\n%d\n", num[N - 2], num[N - 1]);
    } else if (M == 2) {
      d1 = diff[1];
      d2 = diff[2];
      int t = 1;
      idx1 = 0;
      printf("%d", num[0]);
      while (num[t] - num[idx1] == d1) {
        printf(" %d", num[t]);
        idx1 = t;
        t++;
      }
      printf("\n");
      for (; t < N - 1; t++) printf("%d ", num[t]);
      printf("%d\n", num[t]);
    } else {
      if (try1()) {
        construct();
      } else if (try2()) {
        construct();
      } else if (try3()) {
        construct();
      } else if (try4()) {
        construct();
      } else {
        printf("No solution\n");
      }
    }
  }
}
