Cactus Revenge

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

NE(E)RC featured a number of problems in previous years about cactuses --- connected undirected graphs in which every edge belongs to at most one simple cycle. Intuitively, a cactus is a generalization of a tree where some cycles are allowed. The traditional cactus that was initially used in NEERC 2005 problem is given on the second picture in the Examples section.

You are given nn integers d_1,d_2,,d_nd\_1, d\_2, \ldots, d\_n. Construct any cactus with nn vertices such that vertex ii has degree d_id\_i (i. e. exactly d_id\_i incident edges), or determine that no such cactus exists. Parallel edges and loops are not allowed.

입력

The first line contains a single integer nn (2n2,0002 \le n \le 2\\,000) --- the number of vertices in the cactus.

The second line contains nn integers d_1,d_2,,d_nd\_1, d\_2, \ldots, d\_n (1d_in11 \le d\_i \le n-1) --- the desired vertex degrees.

출력

If it's impossible to construct a cactus satisfying the conditions, output a single integer 1-1.

Otherwise, by tradition, output the constructed cactus as a set of edge-distinct paths.

In the first line output an integer mm --- the number of such paths. Each of the following mm lines should contain a path in the graph. A path should start with an integer k_ik\_i (k_i2k\_i \ge 2) followed by k_ik\_i integers from 11 to nn. These k_ik\_i integers should represent consecutive vertices of this path. Adjacent vertices in the path should be distinct. The path can visit the same vertex multiple times, but every edge of the cactus should be traversed exactly once in the whole output.

힌트

Both in the second and the third example, there exist graphs that satisfy the given conditions but none of them are cactuses.