Problem: Vitaly has an array of n distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: 

  1. The product of all numbers in the first set is less than zero ( < 0). 
  2. The product of all numbers in the second set is greater than zero ( > 0). 
  3. The product of all numbers in the third set is equal to zero. 
  4. Each number from the initial array must occur in exactly one set. 



Help Vitaly. Divide the given array.

Input

The first line of the input contains integer n (3 ≤ n ≤ 100). The second line contains n space-separated distinct integers a1, a2, ..., an (|ai| ≤ 103) — the array elements.

Output

In the first line print integer n1 (n1 > 0) — the number of elements in the first set. Then print n1 numbers — the elements that got to the first set.

In the next line print integer n2 (n2 > 0) — the number of elements in the second set. Then print n2 numbers — the elements that got to the second set.

In the next line print integer n3 (n3 > 0) — the number of elements in the third set. Then print n3 numbers — the elements that got to the third set.

The printed sets must meet the described conditions. It is guaranteed that the solution exists. If there are several solutions, you are allowed to print any of them.

Examples

Input

3
-1 2 0


Output

1 -1
1 2
1 0


Input

4
-1 -2 -3 0


Output

1 -1
2 -3 -2
1 0

Solution (in JAVA):

Solution:

import java.io.*;
import java.util.*;

public class NewClass {

    static final int INF = Integer.MAX_VALUE;

    static void mergeSort(int[] a, int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, p, q);
            mergeSort(a, q + 1, r);
            merge(a, p, q, r);
        }
    }

    static void merge(int[] a, int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
        }
        L[n1] = R[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i++];
            } else {
                a[k] = R[j++];
            }
        }
    }

    public static boolean sieve(int n) {
        int a[] = new int[n + 1];
        for (int i = 2; i <= n; i++) {
            a[i] = 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (a[i] == 1) {
                for (int k = 2; i * k <= n; k++) {
                    a[i * k] = 0;
                }
            }
        }
        return a[n] == 1;
    }
public static long sum(int a){
    long su=0;
    while (a>0) {        
        su+=a%10;
        a/=10;
    }
    return su;
}
    public static boolean prime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n%i==0) {
                return true;
            }
        }
        return false;
    }

    public static String reve(int a, int b, String s) {
        String q = "";
        for (int i = b; i >= a; i--) {
            q += s.charAt(i);
        }
        return q;
    }
    public static boolean isvowel(char c){
        if (c=='a' ||c=='e'||c=='i'||c=='o'||c=='u'||c=='y') {
            return true;
        }
        else return false;
    }
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader(System.in);
        OutputWriter or = new OutputWriter(System.out);
      int n = in.nextInt(),co=0;
      int a[] = new int[n];
        for (int i = 0; i < n; i++){
            int h =a[i]= in.nextInt();
            if (h<0) co++;
        }
        Arrays.sort(a);
        List<Integer> o= new ArrayList(),t=new ArrayList(),p=new ArrayList();
        for (int i = 0; i < n; i++) {
            if (a[i]<0 && o.size()==0) {
                o.add(a[i]);
                a[i]=10000;
                co--;
            }
            else if (a[i]==0 && p.size()==0) {
                p.add(a[i]);
                a[i]=10000;
            }
        }
        for (int i = n-1; i>=0; i--) {
            if (a[i]!=10000) {
                if (a[i]>0) {
                    t.add(a[i]);
                    a[i]=10000;
                    break;
                }
                else  {
                    if (co>=2 ||(co>=1 &&t.size()>0)) {
                        t.add(a[i]);
                        a[i]=10000;
                        co--;
                    }
                    if (t.get(t.size()-1)<0 && t.size()%2==0) {
                        break;
                    }
                }
            }
            
        }
        for (int i = 0; i < n; i++) {
            if (a[i]!=10000) p.add(a[i]); 
        }
        or.print(o.size()+" ");
        for (int i = 0; i < o.size(); i++) 
        or.print(o.get(i)+" ");
        or.printLine();
        or.print(t.size()+" ");
        for (int i = 0; i < t.size(); i++) 
        or.print(t.get(i)+" ");
        or.printLine();
        or.print(p.size()+" ");
        for (int i = 0; i < p.size(); i++) 
        or.print(p.get(i)+" ");
        or.flush();
    }
}

class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (snumChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

}

class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}