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 JAVA):

Solution:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> input =  new ArrayList<Integer>();
        input.clear();
        List<Integer> first = new  ArrayList<Integer>();
        List<Integer> second = new ArrayList<Integer>();
        input.clear();
        for (int i = 0; i < n; i ++) {
            input.add(scanner.nextInt());
        }
        if (input.size() == 2) {
            System.out.println(input.get(0));
            System.out.println(input.get(1));
        } else {
            boolean flag = false;
            if (solve(input, first, second, input.get(1) - input.get(0), 0)) {
                flag = true;
            }
            if (flag == false) {
                flag = solve(input, first, second, input.get(2) - input.get(1), 1);
            }
            if (flag == false) {
                flag = solve(input, first, second, input.get(2) - input.get(0), 0);
            }
            if (flag) {
                print(first);
                print(second);
            } else {
                System.out.println("No solution");
            }
        }
    }
    public static void print(List<Integer> list) {
        for (int i = 0; i < list.size(); i ++) {
            if (i > 0) System.out.print(" ");
            System.out.print(list.get(i));
        }
        System.out.println();
    }
    public static boolean solve(List<Integer> input, List<Integer> first,List<Integer> second,int num,int start) {

        first.clear();
        second.clear();
        for (int i = 0; i < start; i ++) second.add(input.get(i));
        first .add(input.get(start));
        int pre = input.get(start);        
        boolean res = true;
        int lastPos = start;
        for (int i = start + 1; i < input.size(); i ++) {
            if (input.get(i) == pre + num) {
                first.add(input.get(i));
                pre = input.get(i);
                lastPos = i;
            } else {
                second.add(input.get(i));
            }
        }
        if (!isIt(second)) {
            first.clear();
            second.clear();
            //System.out.println(lastPos);
            for (int i = 0; i < start; i ++) second.add(input.get(i));
            first .add(input.get(start));
            pre = input.get(start);        
            for (int i = start + 1; i < input.size(); i ++) {
                if (i == lastPos) {
                    second.add(input.get(i));                
                    lastPos = -1;
                    continue;
                }
                if (lastPos == -1)
                    second.add(input.get(i));
                else {
                    if (input.get(i) == pre + num) {
                        first.add(input.get(i));
                        pre = input.get(i);
                       // lastPos = i;
                    } else {
                        second.add(input.get(i));
                    }
                }
            }
            
        }
        return isIt(second) && isIt(first);
    }
    
    public static  boolean isIt(List<Integer> list) {
        if (list.size() == 0) return false;
        else if (list.size() == 1 || list.size() == 2) return true;
        else {
            int num = list.get(1) - list.get(0);
            for (int i = 2; i < list.size(); i ++) {
                if (list.get(i ) != list.get(i - 1) + num) return false; 
            }
            return true;
        }
    }

}