#d11107. 加加减减

加加减减

Add and Subtract

Problem Source

See this link.

Problem Description

Given a sequence {A}\{A\} of length nn.

In each operation you may choose an interval [l,r][l, r] and add 11 to or subtract 11 from all numbers in that interval.

Find the minimum number of operations needed to make all numbers in the sequence equal, and also, under the condition of using the minimum number of operations, how many different final sequences can be obtained.

Input Format

One line with an integer nn (n≤106n \le 10^6), the length of the array.

One line with nn integers, the ii-th being AiA_i (∣Ai∣|A_i| is within the range of int).

Output Format

The first line outputs the minimum number of operations.

The second line outputs how many different results can be obtained in the end.

Sample Input

4
1 1 2 2

Sample Output

1
2

Constraints

  • 1≤n≤1061 \le n \le 10^6.
  • ∣Ai∣|A_i| is within the range of a 32-bit signed integer.