#include <bits/stdc++.h>
bool solve(const std::vector<int64_t>& a, int64_t b1, int64_t d1, int64_t p1,
           int64_t b2, int64_t d2, int64_t p2, std::vector<int64_t>& v1,
           std::vector<int64_t>& v2) {
  if (p1 + p2 == int64_t(a.size())) {
    return true;
  }
  if (a[p1 + p2] == b1 + d1 * p1) {
    if (solve(a, b1, d1, p1 + 1, b2, d2, p2, v1, v2)) {
      v1.push_back(a[p1 + p2]);
      return true;
    }
  }
  if (a[p1 + p2] == b2 + d2 * p2) {
    if (solve(a, b1, d1, p1, b2, d2, p2 + 1, v1, v2)) {
      v2.push_back(a[p1 + p2]);
      return true;
    }
  }
  return false;
}
bool solve(const std::vector<int64_t>& a, int64_t b1, int64_t d1, int64_t p1,
           int64_t b2, std::vector<int64_t>& v1, std::vector<int64_t>& v2) {
  if (p1 + 1 == int64_t(a.size())) {
    return true;
  }
  if (a[p1 + 1] == b1 + d1 * p1) {
    if (solve(a, b1, d1, p1 + 1, b2, v1, v2)) {
      v1.push_back(a[p1 + 1]);
      return true;
    }
  }
  if (solve(a, b1, d1, p1, b2, a[p1 + 1] - b2, 2, v1, v2)) {
    v2.push_back(a[p1 + 1]);
    return true;
  }
  return false;
}
bool solve1(const std::vector<int64_t>& a, std::vector<int64_t>& v1,
            std::vector<int64_t>& v2) {
  const int64_t d1 = a[1] - a[0];
  const int64_t b1 = a[0];
  const int64_t b2 = a[2];
  bool ok = solve(a, b1, d1, 2, b2, v1, v2);
  if (!ok) {
    return false;
  }
  v1.push_back(a[1]);
  v1.push_back(a[0]);
  v2.push_back(a[2]);
  std::reverse(v1.begin(), v1.end());
  std::reverse(v2.begin(), v2.end());
  return true;
}
bool solve2(const std::vector<int64_t>& a, std::vector<int64_t>& v1,
            std::vector<int64_t>& v2) {
  const int64_t d1 = a[2] - a[0];
  const int64_t b1 = a[0];
  const int64_t b2 = a[1];
  bool ok = solve(a, b1, d1, 2, b2, v1, v2);
  if (!ok) {
    return false;
  }
  v1.push_back(a[2]);
  v1.push_back(a[0]);
  v2.push_back(a[1]);
  std::reverse(v1.begin(), v1.end());
  std::reverse(v2.begin(), v2.end());
  return true;
}
bool solve3(const std::vector<int64_t>& a, std::vector<int64_t>& v1,
            std::vector<int64_t>& v2) {
  const int64_t d1 = a[2] - a[1];
  const int64_t b1 = a[1];
  const int64_t b2 = a[0];
  bool ok = solve(a, b1, d1, 2, b2, v1, v2);
  if (!ok) {
    return false;
  }
  v1.push_back(a[2]);
  v1.push_back(a[1]);
  v2.push_back(a[0]);
  std::reverse(v1.begin(), v1.end());
  std::reverse(v2.begin(), v2.end());
  return true;
}
bool solve4(const std::vector<int64_t>& a, std::vector<int64_t>& v1,
            std::vector<int64_t>& v2) {
  const int64_t d1 = a[1] - a[0];
  const int64_t b1 = a[0];
  int64_t p1 = 2;
  const int64_t n = a.size();
  int64_t last = 1;
  std::vector<int64_t> used(n);
  used[0] = 1;
  used[1] = 1;
  for (int64_t i = 2; i < n; ++i) {
    if (a[i] == b1 + d1 * p1) {
      used[i] = 1;
      p1 += 1;
      last = i;
    }
  }
  if (p1 == n) {
    v1.insert(v1.end(), a.begin(), a.end() - 1);
    v2.push_back(a.back());
    return true;
  }
  for (int64_t i = 0; i < n; ++i) {
    if (used[i]) {
      v1.push_back(a[i]);
    } else {
      v2.push_back(a[i]);
    }
  }
  if (v2.size() <= 2) {
    return true;
  }
  bool ok = true;
  for (int64_t i = 2; ok && i < int64_t(v2.size()); ++i) {
    ok &= v2[i] == v2[0] + (v2[1] - v2[0]) * i;
  }
  if (ok) {
    return true;
  }
  v2.clear();
  v1.pop_back();
  for (int64_t i = 0; i < n; ++i) {
    if (!used[i] || i == last) {
      v2.push_back(a[i]);
    }
  }
  ok = true;
  for (int64_t i = 2; ok && i < int64_t(v2.size()); ++i) {
    ok &= v2[i] == v2[0] + (v2[1] - v2[0]) * i;
  }
  if (ok) {
    return true;
  }
  v1.clear();
  v2.clear();
  return false;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  size_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  for (size_t i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  if (n == 2) {
    std::cout << a[0] << '\n' << a[1] << '\n';
    return 0;
  }
  std::vector<int64_t> v1;
  std::vector<int64_t> v2;
  if (solve1(a, v1, v2) || solve2(a, v1, v2) || solve3(a, v1, v2) ||
      solve4(a, v1, v2)) {
    for (int64_t x : v1) {
      std::cout << x << ' ';
    }
    std::cout << '\n';
    for (int64_t x : v2) {
      std::cout << x << ' ';
    }
    std::cout << '\n';
  } else {
    std::cout << "No solution\n";
  }
}
