#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int g;
  cin >> n;
  int* a = new int[n];
  int* b = new int[n];
  int x0;
  int x1;
  int d0;
  int d1;
  int m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  b[0] = 0;
  b[1] = 0;
  d0 = a[1] - a[0];
  x0 = a[1];
  m = 2;
  while ((m < n) && ((a[m] - x0) == d0)) {
    x0 = a[m];
    b[m] = 0;
    ++m;
  }
  if (m == n) {
    cout << a[0] << "\n" << a[1];
    for (int i = 2; i < n; ++i) cout << " " << a[i];
    cout << "\n";
    return 0;
  }
  b[m] = 1;
  x1 = a[m];
  g = 0;
  int tmp;
  g = 2;
  for (int j = -1; j < 2; ++j) {
    if (g == 2) {
      int i;
      if (j > -1) {
        d0 = a[2] - a[j];
        x1 = a[1 - j];
        x0 = a[2];
        b[0] = j;
        b[1] = 1 - j;
        b[2] = 0;
        i = 3;
      } else {
        i = m + 1;
      }
      g = 0;
      for (; i < n; ++i) {
        if ((a[i] - x0) == d0) {
          if (g == 0) {
            tmp = x1;
            d1 = a[i] - x1;
            x1 = a[i];
            b[i] = 1;
            for (int k = i + 1; k < n; ++k) {
              if ((a[k] - x1) == d1) {
                x1 = a[k];
                b[k] = 1;
              } else {
                g = 2;
                break;
              }
            }
            if (g == 2) {
              x1 = tmp;
              g = 0;
            } else
              break;
          }
          if (g && ((a[i] - x1) == d1)) {
            tmp = x0;
            x0 = a[i];
            b[i] = 0;
            for (int k = i + 1; k < n; ++k) {
              if ((a[k] - x0) == d0) {
                x0 = a[k];
                b[k] = 0;
              } else {
                g = 2;
                break;
              }
            }
            if (g == 2) {
              g = 0;
              x0 = tmp;
              x1 = a[i];
              b[i] = 1;
              for (int k = i + 1; k < n; ++k) {
                if ((a[k] - x1) == d1) {
                  x1 = a[k];
                  b[k] = 1;
                } else {
                  g = 2;
                  break;
                }
              }
            }
            break;
          } else {
            b[i] = 0;
            x0 = a[i];
          }
        } else if (g) {
          if ((a[i] - x1) == d1) {
            b[i] = 1;
            x1 = a[i];
          } else {
            g = 2;
            break;
          }
        } else {
          g = 1;
          b[i] = 1;
          d1 = a[i] - x1;
          x1 = a[i];
        }
      }
    }
  }
  if (g == 2)
    cout << "No solution\n";
  else {
    for (int i = 0; i < n; ++i) {
      if (b[i] == 0) {
        if (a[i] == x0)
          cout << x0;
        else
          cout << a[i] << " ";
      }
    }
    cout << "\n";
    for (int i = 0; i < n; ++i) {
      if (b[i] == 1) {
        if (a[i] == x1)
          cout << x1;
        else
          cout << a[i] << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
