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>
using namespace std;
vector<long long> a;
void prnt(vector<long long> &a1, vector<long long> &b1) {
  sort(a1.begin(), a1.end());
  sort(b1.begin(), b1.end());
  if (!a1.size()) {
    a1.push_back(b1.back());
    b1.pop_back();
  } else if (!b1.size()) {
    b1.push_back(a1.back());
    a1.pop_back();
  }
  for (long long i = 0; i < a1.size(); ++i) {
    cout << a[a1[i]] << " ";
  }
  cout << "\n";
  for (long long j = 0; j < b1.size(); ++j) {
    cout << a[b1[j]] << " ";
  }
  cout << "\n";
  exit(0);
}
void solve() {
  long long n;
  cin >> n;
  a.resize(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (n == 2) {
    cout << a[0] << "\n";
    cout << a[1] << "\n";
    return;
  } else if (n == 3) {
    cout << a[0] << " " << a[1] << "\n";
    cout << a[2] << "\n";
    return;
  } else if (n == 4) {
    cout << a[0] << " " << a[1] << "\n";
    cout << a[2] << " " << a[3] << "\n";
    return;
  }
  vector<pair<long long, long long> > g = {{0, 1}, {0, 2}, {1, 2}};
  for (auto cur : g) {
    bool ok = 1;
    long long st = cur.first;
    long long d = a[cur.second] - a[cur.first];
    vector<long long> ai, bi;
    if (st) {
      ai.push_back(st);
      bi.push_back(0);
    } else {
      ai.push_back(0);
    }
    long long pr = st;
    for (long long i = st + 1; i < n; ++i) {
      if (a[i] - a[pr] == d) {
        pr = i;
        ai.push_back(i);
      } else {
        bi.push_back(i);
      }
    }
    map<long long, long long> df, sdf;
    for (long long i = 1; i < bi.size(); ++i) {
      df[a[bi[i]] - a[bi[i - 1]]]++;
    }
    if (df.size() <= 1) {
      prnt(ai, bi);
    } else {
      set<long long> nbi, rnbi;
      for (long long i : bi) nbi.insert(i);
      for (long long i : bi) rnbi.insert(-i);
      long long rssf = -1;
      long long rspr = -1;
      for (long long sf = ai.size() - 1; sf >= 0; --sf) {
        auto kek = nbi.lower_bound(ai[sf]);
        auto kek1 = rnbi.lower_bound(-ai[sf]);
        if (kek == nbi.end()) {
          long long nw = a[ai[sf]] - a[*(--nbi.end())];
          df[nw]++;
        } else if (kek1 == rnbi.end()) {
          long long nw = a[*(nbi.begin())] - a[ai[sf]];
          df[nw]++;
        } else {
          long long old = a[*kek] - a[-*kek1];
          long long nw1 = a[*kek] - a[ai[sf]];
          long long nw2 = a[ai[sf]] - a[-*kek1];
          df[old]--;
          if (df[old] == 0) df.erase(old);
          df[nw1]++;
          df[nw2]++;
        }
        nbi.insert(ai[sf]), rnbi.insert(-ai[sf]);
        if (df.size() == 1) {
          rssf = sf;
          break;
        }
      }
      if (rssf != -1) {
        for (long long i = rssf; i < ai.size(); ++i) {
          bi.push_back(ai[i]);
        }
        while (ai.size() != rssf) {
          ai.pop_back();
        }
        prnt(ai, bi);
      }
    }
  }
  cout << "No solution\n";
}
signed main() {
  long long t = 1;
  cout << fixed << setprecision(10);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  while (t--) {
    solve();
  }
}