**5 人解决**，8 人已尝试。

**37 份提交通过**，共有 82 份提交。

**7.3** EMB 奖励。

**单点时限: **10.0 sec

**内存限制: **256 MB

There are S people swimming in the pool.
At some point, the coach notices that their distribution over pool lanes is quite uneven, which is a nuisance for pool visitors. Changing the lane across ropes, however, poses a nuisance for a swimmer.

To form a nice distribution over the lanes the number of swimmers on each pair of adjacent lanes should differ by at most one. In particular, an empty lane should only be adjacent to another empty one or a lane occupied by only one swimmer.

Your task is to calculate the minimum number of swimmers’ lane changes needed to meet this condition.

Output the minimum possible number of lane changes that are needed to meet a desired distribution.

Input

3 8 0 2 3 8 5 7

Output

5 1

**5 人解决**，8 人已尝试。

**37 份提交通过**，共有 82 份提交。

**7.3** EMB 奖励。

**创建**: 9 年，4 月前.

**修改**: 3 年前.

**最后提交**: 7 年，5 月前.

**来源**: N/A

题目标签