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;
const int maxn = 30005;
int a[maxn];
int b[maxn], c[maxn];
bool used[maxn];
int n, bn, cn;
void print() {
  for (int i = 1; i <= bn; i++) printf("%d ", b[i]);
  printf("\n");
  for (int i = 1; i <= cn; i++) printf("%d ", c[i]);
  printf("\n");
}
bool judgeC() {
  int i;
  int cd = c[2] - c[1];
  bool flag = true;
  i = 3;
  while (i <= cn) {
    if (c[i] - c[i - 1] != cd) {
      flag = false;
      break;
    }
    i++;
  }
  if (flag) return true;
  return false;
}
bool judgeB() {
  int i;
  int bd = b[2] - b[1];
  bool flag = true;
  i = 3;
  while (i <= bn) {
    if (b[i] - b[i - 1] != bd) {
      flag = false;
      break;
    }
    i++;
  }
  if (flag) return true;
  return false;
}
bool judge() {
  int i;
  used[1] = false;
  cn = 0;
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (judgeC()) {
    for (i = 2; i <= bn; i++) printf("%d ", b[i]);
    printf("\n");
    for (i = 1; i <= cn; i++) printf("%d ", c[i]);
    printf("\n");
    return true;
  }
  used[1] = true;
  int tmp = b[bn];
  for (i = 1; i <= n; i++)
    if (a[i] == tmp) break;
  used[i] = false;
  cn = 0;
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (judgeC()) {
    bn--;
    print();
    return true;
  }
  return false;
}
bool solve1() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  b[++bn] = a[1];
  used[1] = true;
  if (a[2] - a[1] == a[3] - a[2]) {
    b[++bn] = a[2];
    b[++bn] = a[3];
    used[2] = used[3] = true;
    int d = b[2] - b[1];
    i = 4;
    while (i <= n) {
      if (a[i] - b[bn] == d) {
        b[++bn] = a[i];
        used[i] = true;
      }
      i++;
    }
    for (i = 1; i <= n; i++)
      if (!used[i]) c[++cn] = a[i];
    if (cn == 0) {
      c[++cn] = b[bn];
      bn--;
      print();
      return true;
    } else if (cn == 1 || cn == 2) {
      print();
      return true;
    } else {
      int cd = c[2] - c[1];
      bool flag = true;
      i = 3;
      while (i <= cn) {
        if (c[i] - c[i - 1] != cd) {
          flag = false;
          break;
        }
        i++;
      }
      if (flag) {
        print();
        return true;
      } else if (judge())
        return true;
    }
  }
  return false;
}
bool solve2() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  c[++cn] = a[2];
  c[++cn] = a[3];
  used[2] = true;
  used[3] = true;
  int d = c[2] - c[1];
  i = 4;
  while (i <= n) {
    if (a[i] - c[cn] == d) {
      c[++cn] = a[i];
      used[i] = true;
    }
    i++;
  }
  for (i = 1; i <= n; i++)
    if (!used[i]) b[++bn] = a[i];
  if (bn == 1 || bn == 2) {
    print();
    return true;
  } else {
    bool flag = true;
    int bd = b[2] - b[1];
    i = 3;
    while (i <= bn) {
      if (b[i] - b[i - 1] != bd) {
        flag = false;
        break;
      }
      i++;
    }
    if (flag) {
      print();
      return true;
    } else {
      used[2] = false;
      bn = 0;
      for (i = 1; i <= n; i++)
        if (!used[i]) b[++bn] = a[i];
      if (judgeB()) {
        for (i = 1; i <= bn; i++) printf("%d ", b[i]);
        printf("\n");
        for (i = 2; i <= cn; i++) printf("%d ", c[i]);
        printf("\n");
        return true;
      }
      int tmp = c[cn];
      for (i = 1; i <= n; i++)
        if (tmp == a[i]) break;
      used[2] = true;
      used[i] = false;
      bn = 0;
      for (i = 1; i <= n; i++)
        if (!used[i]) b[++bn] = a[i];
      if (judgeB()) {
        cn--;
        print();
        return true;
      }
    }
  }
  return false;
}
bool solve3() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  b[++bn] = a[1];
  b[++bn] = a[2];
  used[1] = true;
  used[2] = true;
  int d = b[2] - b[1];
  i = 4;
  while (i <= n) {
    if (a[i] - b[bn] == d) {
      b[++bn] = a[i];
      used[i] = true;
    }
    i++;
  }
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (cn == 1 || cn == 2) {
    print();
    return true;
  } else {
    bool flag = true;
    int cd = c[2] - c[1];
    i = 3;
    while (i <= cn) {
      if (c[i] - c[i - 1] != cd) {
        flag = false;
        break;
      }
      i++;
    }
    if (flag) {
      print();
      return true;
    } else if (judge())
      return true;
  }
  return false;
}
bool solve4() {
  int i;
  bn = cn = 0;
  memset(used, false, sizeof(used));
  b[++bn] = a[1];
  b[++bn] = a[3];
  used[1] = true;
  used[3] = true;
  int d = b[2] - b[1];
  i = 4;
  while (i <= n) {
    if (a[i] - b[bn] == d) {
      b[++bn] = a[i];
      used[i] = true;
    }
    i++;
  }
  for (i = 1; i <= n; i++)
    if (!used[i]) c[++cn] = a[i];
  if (cn == 1 || cn == 2) {
    print();
    return true;
  } else {
    bool flag = true;
    int cd = c[2] - c[1];
    i = 3;
    while (i <= cn) {
      if (c[i] - c[i - 1] != cd) {
        flag = false;
        break;
      }
      i++;
    }
    if (flag) {
      print();
      return true;
    } else if (judge())
      return true;
  }
  return false;
}
int main() {
  int i;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    if (n == 2) {
      cout << a[1] << endl;
      cout << a[2] << endl;
      continue;
    } else if (n == 3) {
      cout << a[1] << " " << a[2] << endl;
      cout << a[3] << endl;
      continue;
    } else {
      if (solve1())
        continue;
      else if (solve2())
        continue;
      else if (solve3())
        continue;
      else if (solve4())
        continue;
      else
        cout << "No solution" << endl;
    }
  }
  return 0;
}