402806: GYM100886 A Three Servers

Memory Limit:0 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Three Serverstime limit per test5 secondsmemory limit per test256 mebibytesinputstandard inputoutputstandard output

There are three identical servers and n requests to process. The time to process each request is known: it takes ti seconds to process the i-th request on any server.

You want to assign requests to servers in the most fair way. For each server, find its load: the total time required to process all requests assigned to this server. The assignment is the most fair if the difference between maximum and minimum load of the three servers is as small as possible.

Input

The first line contains an integer n (1 ≤ n ≤ 400), the number of requests. The second line contains the sequence of integer numbers t1, t2, ..., tn (1 ≤ ti ≤ 30) where ti is the time to process the i-th request.

Output

Print four lines. The first line must contain the smallest possible difference between the maximum and minimum load of servers. Each of the following three lines must contain the description of requests assigned to a server. A description must start with the number of assigned requests, followed by the indices of these requests in any order.

If there are several possible answers, print any one of them.

ExamplesInput
6
7 3 20 1 5 7
Output
9
1 3
3 2 4 1
2 5 6
Input
3
7 7 7
Output
0
1 3
1 2
1 1

加入题单

算法标签: