Marble Madness

No attempts yetTime limit1sMemory limit256 MB

Problem

Mirko is playing with marbles. There are n bins placed in a row from left to right, and each bin holds some number of marbles. In one move Mirko can take a single marble from a bin and put it into a bin next to it. A bin next to another one is a bin that shares a side with it. He can move the same marble several times, and every move is counted separately.

When the game ends, the score is the sum of the absolute differences between the marble counts of each pair of neighbouring bins. For example, if nine bins end up holding 9, 8, 3, 2, 7, 2, 3, 4, 6 marbles from left to right, the score is

98+83+32+27+72+23+34+46=1+5+1+5+5+1+1+2=21|9-8| + |8-3| + |3-2| + |2-7| + |7-2| + |2-3| + |3-4| + |4-6| = 1 + 5 + 1 + 5 + 5 + 1 + 1 + 2 = 21

Mirko wants the largest score he can reach, and among the ways to reach that score he wants the smallest number of moves. Find both values.

Input

The first line has the number of bins n (1n1000001 \le n \le 100\,000).

The second line has n integers m (0m10000 \le m \le 1\,000), separated by single spaces, giving the number of marbles in each bin from left to right.

Output

Print one line with two integers separated by a single space. The first is the largest score Mirko can reach, and the second is the smallest number of moves needed to reach that score. Print no extra spaces.