Problem: An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progression. The definition implies that any sequences whose length equals 1 or 2 are arithmetic and all sequences whose length equals 0 are non-arithmetic.

You are given a sequence of different integers a1, a2, ..., an. You should either split it into two arithmetic progressions or find out that the operation is impossible to perform. Splitting assigns each member of the given sequence to one of two progressions, but the relative order of numbers does not change. Splitting is an inverse operation to merging.

Input

The first line contains a positive integer n (2 ≤ n ≤ 30000), n is the length of the given sequence. The second line contains elements of the given sequence a1, a2, ..., an ( - 108 ≤ ai ≤ 108). The elements of the progression are different integers.

Output

Print the required arithmetic progressions, one per line. The progressions can be positioned in any order. Each progression should contain at least one number. If there's no solution, then print "No solution" (without the quotes)in the only line of the input file. If there are several solutions, print any of them.

Examples

Input

6
4 1 2 7 3 10


Output

1 2 3 
4 7 10 


Input

5
1 2 3 -2 -7


Output

1 2 3 
-2 -7 

Note

In the second sample another solution is also possible (number three can be assigned to the second progression): 1, 2 and 3, -2, -7.

Solution (in CPP):

Solution:
#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";
  }
}