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<int> v;
int n;
bool sePuede(int i12) {
  int i11 = 1;
  int c1 = 2;
  int r1 = v[i12] - v[1];
  int i21, i22;
  int c2 = i12 - 1 - 1;
  int r2 = 0;
  if (c2 >= 1) {
    i21 = 2;
  }
  if (c2 >= 2) {
    i22 = 3;
    r2 = v[i22] - v[i21];
  }
  bool posible = true;
  for (int i = i12 + 1; i <= n; ++i) {
    int e = v[i];
    if (e == v[i11] + r1 * c1) {
      if (c2 == 0) {
        c1 += 1;
        continue;
      } else if (c2 == 1) {
        int temp_r2 = v[i] - v[i21];
        int temp_c2 = 2;
        int temp_posible = true;
        for (int j = i + 1; j <= n; ++j) {
          if (v[j] == v[i21] + temp_r2 * temp_c2) {
            temp_c2 += 1;
          } else {
            temp_posible = false;
            break;
          }
        }
        if (temp_posible) {
          posible = true;
          break;
        }
      } else if (c2 >= 2 && e == v[i21] + r2 * c2) {
        int temp_c2 = c2 + 1;
        int temp_posible = true;
        for (int j = i + 1; j <= n; ++j) {
          if (v[j] == v[i21] + r2 * temp_c2) {
            temp_c2 += 1;
          } else {
            temp_posible = false;
            break;
          }
        }
        if (temp_posible) {
          posible = true;
          break;
        }
      }
      c1 += 1;
    } else {
      if (c2 == 0) {
        i21 = i;
        c2 += 1;
      } else if (c2 == 1) {
        i22 = i;
        r2 = v[i22] - v[i21];
        c2 += 1;
      } else if (e != v[i21] + r2 * c2) {
        posible = false;
        break;
      } else {
        c2 += 1;
      }
    }
  }
  return posible;
}
void construir(int i12) {
  list<int> l1, l2;
  int i11 = 1;
  int c1 = 2;
  int r1 = v[i12] - v[1];
  int i21, i22;
  int c2 = i12 - 1 - 1;
  int r2 = 0;
  if (c2 >= 1) {
    i21 = 2;
  }
  if (c2 >= 2) {
    i22 = 3;
    r2 = v[i22] - v[i21];
  }
  l1.push_back(v[i11]);
  l1.push_back(v[i12]);
  for (int i = i11 + 1; i < i12; ++i) {
    l2.push_back(v[i]);
  }
  bool posible = true;
  for (int i = i12 + 1; i <= n; ++i) {
    int e = v[i];
    if (e == v[i11] + r1 * c1) {
      if (c2 == 0) {
        l1.push_back(e);
        c1 += 1;
        continue;
      } else if (c2 == 1) {
        int temp_r2 = v[i] - v[i21];
        int temp_c2 = 2;
        int temp_posible = true;
        for (int j = i + 1; j <= n; ++j) {
          if (v[j] == v[i21] + temp_r2 * temp_c2) {
            temp_c2 += 1;
          } else {
            temp_posible = false;
            break;
          }
        }
        if (temp_posible) {
          l2.push_back(e);
          for (int j = i + 1; j <= n; ++j) {
            l2.push_back(v[j]);
          }
          posible = true;
          break;
        }
      } else if (c2 >= 2 && e == v[i21] + r2 * c2) {
        int temp_c2 = c2 + 1;
        int temp_posible = true;
        for (int j = i + 1; j <= n; ++j) {
          if (v[j] == v[i21] + r2 * temp_c2) {
            temp_c2 += 1;
          } else {
            temp_posible = false;
            break;
          }
        }
        if (temp_posible) {
          l2.push_back(e);
          for (int j = i + 1; j <= n; ++j) {
            l2.push_back(v[j]);
          }
          posible = true;
          break;
        }
      }
      c1 += 1;
      l1.push_back(e);
    } else {
      if (c2 == 0) {
        l2.push_back(e);
        i21 = i;
        c2 += 1;
      } else if (c2 == 1) {
        l2.push_back(e);
        i22 = i;
        r2 = v[i22] - v[i21];
        c2 += 1;
      } else if (e != v[i21] + r2 * c2) {
        posible = false;
        break;
      } else {
        l2.push_back(e);
        c2 += 1;
      }
    }
  }
  if (l2.size() == 0) {
    list<int>::iterator it = l1.end();
    --it;
    l2.push_back(*it);
    l1.erase(it);
  }
  for (list<int>::iterator it = l1.begin(); it != l1.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
  for (list<int>::iterator it = l2.begin(); it != l2.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}
int main() {
  cin >> n;
  v.resize(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  int i21, i22, r2, c2 = 0;
  bool solved = false;
  int i;
  for (i = 2; i <= n; ++i) {
    if (sePuede(i)) {
      construir(i);
      solved = true;
      break;
    } else {
      if (c2 == 0) {
        i21 = i;
        c2 += 1;
      } else if (c2 == 1) {
        i22 = i;
        r2 = v[i22] - v[i21];
        c2 += 1;
      } else {
        if (v[i] == v[i21] + r2 * c2) {
          c2 += 1;
        } else {
          solved = false;
          break;
        }
      }
    }
  }
  if (!solved) {
    cout << "No solution" << endl;
  }
  return 0;
}