Gugulu, a JBer, who was an ACMer two years ago, comes to HDOJ taking part in the 2020 Multi
University Training Contest again. However, every time when Gugulu came to regional, he always got
an Iron Medal and would consider this competition JB-like. To release his pain, Gugulu would go to
the Shanghai Disneyland Park to have fun in taking the Roller Coaster. Gugulu loves the feeling with
high-level blood pressure so much which makes him feel like a happy flflappy bird who forgets all the Wrong
Answers and Time Limit Exceededs etc.
We can regard the path of the Roller Coaster as a list of turning points with difffferent heights which can
be represented as an array {a1, a2, a3, . . . , an} of size n, and Gugulu’s fifinal blood pressure after the game
of the Roller Coaster is counted as the sum of all absolute values of the difffferences between the n n 1
pairs of adjacent array numbers, i.e. Pnn
1
i=1
|ai i ai+1|.
Gugulu always got Iron Medals and is always getting Iron Medals, which makes him keep taking the
Roller Coaster over and over again. However, as playing more games, his threshold on the value of blood
pressure which can make himself happy is keeping increasing. As a result, the Roller Coaster of Shanghai
Disneyland Park can hardly meet Gugulu’s needs anymore.
Therefore, Gugulu decides to rearrange the array {a1, a2, a3, . . . , an} in any order to make his blood
pressure as high as possible. Moreover, he wants to know the largest k distinct possible values of blood
pressure that can be achieved and the number of the corresponding permutations.
You, another JBer, are sure that Gugulu is clever enough to get the highest blood pressure as he can. It is
very important for you to calculate the correct answer to make an appointment with a proper cardiologist
in advance to save Gugulu’s life. You must solve this problem! Gugulu’s blood pressure is becoming out
of control!