#include <bits/stdc++.h>
using namespace std;
int arr1[300001] = {0};
int arr2[300001] = {0};
int arr3[300001] = {0};
void printvector(vector<long long int>& vec) {
  for (long long int i = 0; i < vec.size(); i++) cout << vec[i] << ' ';
  cout << endl;
  return;
}
int main() {
  long long int n;
  cin >> n;
  vector<long long int> vec(n);
  vector<long long int> ans1a;
  vector<long long int> ans1b;
  vector<long long int> ans2a;
  vector<long long int> ans2b;
  vector<long long int> ans3a;
  vector<long long int> ans3b;
  for (long long int i = 0; i < n; i++) cin >> vec[i];
  if (n == 1) {
    cout << "No solution" << endl;
    return 0;
  }
  if (n == 2) {
    cout << vec[0] << '\n' << vec[1] << '\n';
    return 0;
  }
  long long int a = vec[vec.size() - 3];
  long long int b = vec[vec.size() - 2];
  long long int c = vec[vec.size() - 1];
  long long int r1 = c - a;
  long long int ini1 = vec.size() - 1;
  long long int r2 = c - b;
  long long int ini2 = vec.size() - 1;
  long long int r3 = b - a;
  long long int ini3 = vec.size() - 2;
  arr1[ini1] = 1;
  arr2[ini2] = 1;
  arr3[ini3] = 1;
  long long int curr = ini1;
  for (long long int i = ini1 - 1; i >= 0; i--) {
    if (vec[curr] - vec[i] == r1) {
      curr = i;
      arr1[i] = 1;
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (arr1[i]) {
      ans1a.push_back(vec[i]);
    } else {
      ans1b.push_back(vec[i]);
    }
  }
  bool pos1 = true;
  if (ans1b.size() == 1) {
    pos1 = true;
  } else if (ans1b.size() == 0) {
    pos1 = false;
  } else {
    long long int r11 = ans1b[1] - ans1b[0];
    for (long long int i = 1; i < ans1b.size(); i++) {
      if (ans1b[i] - ans1b[i - 1] != r11) {
        pos1 = false;
        break;
      }
    }
  }
  if (pos1 == true) {
    for (long long int i = 0; i < ans1a.size(); i++) cout << ans1a[i] << ' ';
    cout << endl;
    for (long long int i = 0; i < ans1b.size(); i++) cout << ans1b[i] << ' ';
    cout << endl;
    return 0;
  }
  curr = ini2;
  for (long long int i = ini2 - 1; i >= 0; i--) {
    if (vec[curr] - vec[i] == r2) {
      curr = i;
      arr2[i] = 1;
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (arr2[i]) {
      ans2a.push_back(vec[i]);
    } else {
      ans2b.push_back(vec[i]);
    }
  }
  bool pos2 = true;
  if (ans2b.size() == 1) {
    pos2 = true;
  } else if (ans2b.size() == 0) {
    pos2 = false;
  } else {
    long long int r22 = ans2b[1] - ans2b[0];
    for (long long int i = 1; i < ans2b.size(); i++) {
      if (ans2b[i] - ans2b[i - 1] != r22) {
        pos2 = false;
        break;
      }
    }
  }
  if (pos2 == true) {
    for (long long int i = 0; i < ans2a.size(); i++) cout << ans2a[i] << ' ';
    cout << endl;
    for (long long int i = 0; i < ans2b.size(); i++) cout << ans2b[i] << ' ';
    cout << endl;
    return 0;
  }
  curr = ini3;
  for (long long int i = ini3 - 1; i >= 0; i--) {
    if (vec[curr] - vec[i] == r3) {
      curr = i;
      arr3[i] = 1;
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (arr3[i]) {
      ans3a.push_back(vec[i]);
    } else {
      ans3b.push_back(vec[i]);
    }
  }
  bool pos3 = true;
  if (ans3b.size() == 1) {
    pos3 = true;
  } else if (ans3b.size() == 0) {
    pos3 = false;
  } else {
    long long int r33 = ans3b[1] - ans3b[0];
    for (long long int i = 1; i < ans3b.size(); i++) {
      if (ans3b[i] - ans3b[i - 1] != r33) {
        pos3 = false;
        break;
      }
    }
  }
  if (pos3 == true) {
    for (long long int i = 0; i < ans3a.size(); i++) cout << ans3a[i] << ' ';
    cout << endl;
    for (long long int i = 0; i < ans3b.size(); i++) cout << ans3b[i] << ' ';
    cout << endl;
    return 0;
  }
  cout << "No solution" << endl;
  return 0;
}
