Remix

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

문제

You are given a multiset ss consisting of nn integers. You should perform the following three-step operation some number of times until a single integer remains in ss.

  • Choose a multiset tt such that tst \subseteq s and t2|t| \ge 2.
  • Erase the elements of tt from ss.
  • Insert max(t)min(t)\max(t) - \min(t) to ss.

Find a sequence of operations that maximizes the integer left in ss.

입력

The first line contains a single integer nn (2n105)(2 \le n \le 10^5).

The second line contains nn integers s_1,s_2,,s_ns\_1, s\_2, \ldots, s\_n (0s_i105)(0 \le s\_i \le 10^5).

출력

On the first line, print a single integer kk (1kn1)(1 \le k \le n-1), the number of operations.

On each of the next kk lines, print an integer mm (2mn)(2 \le m \le n), the size of the chosen multiset tt, followed by mm integers, t_1,t_2,,t_mt\_1, t\_2, \ldots, t\_m.

Note that the operations are executed in the same order they are listed. So, for each operation, tt must be a subset of ss when all the preceding operations are performed.

힌트

The sample does the following operations:

 Chosen ttNew ss
00 24,33,48,63,90,93,97\\{24, 33, 48, 63, 90, 93, 97\\}
1133,90,93\\{33, 90, 93\\}24,48,60,63,97\\{24, 48, \underline{60}, 63, 97\\}
2260,63\\{60, 63\\}3,24,48,97\\{\underline{3}, 24, 48, 97\\}
3324,48\\{24, 48\\}3,24,97\\{3, \underline{24}, 97\\}
443,24,97\\{3, 24, 97\\}94\\{\underline{94}\\}

The values underlined in ss denote the integer inserted. After the fourth operation, ss is reduced to a single integer value of 9494. It can be shown that no other sequence of operations results in a larger value.