#P4552. [Poetize6] IncDec Sequence

[Poetize6] IncDec Sequence

Description

Given a sequence of length nn, a1,a2,,an{a_1,a_2,\cdots,a_n}, in each operation you may choose an interval [l,r][l, r] and either add 11 to every number in this interval or subtract 11 from every number in this interval.

What is the minimum number of operations needed to make all numbers in the sequence equal, and under this minimum, how many different final sequences are possible?

Input Format

The first line contains a positive integer nn. Then nn lines follow; the integer on the (i+1)(i+1)-th line is aia_i.

Output Format

Output the minimum number of operations on the first line. Output the number of possible final sequences on the second line.

4
1
1
2
2
1
2

Hint

Constraints: For 100%100\% of the testdata, n100000n \le 100000, 0ai2310 \le a_i \le 2^{31}.

Translated by ChatGPT 5