码农谷 > 问答 > 编程题 > Bear and Blocks

Bear and Blocks

提问者: 老码农     发布时间:2017-01-11     浏览:41     回复:0     悬赏:0.0 谷币

Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample.

Limak will repeat the following operation till everything is destroyed.

Block is called internal if it has all four neighbors, i.e. it has each side (top, left, down and right) adjacent to other block or to the floor. Otherwise, block is boundary. In one operation Limak destroys all boundary blocks. His paws are very fast and he destroys all those blocks at the same time.

Limak is ready to start. You task is to count how many operations will it take him to destroy all towers.

Input

The first line contains single integer n (1 ≤ n ≤ 105).

The second line contains n space-separated integers h1, h2, ..., hn (1 ≤ hi ≤ 109) — sizes of towers.

Output

Print the number of operations needed to destroy all towers.


输入样例:
6
2 1 4 6 2 2

输出样例:
3

我要挑战
其他解答 共0条
 
温馨提示:本问答中心的任何言论仅代表发言者个人的观点,与码农谷立场无关。请对您的言论负责,遵守中华人民共和国有关法律、法规。如果您的言论违反码农谷问答中心的规则,将会被删除。
验证码: 看不清?点击图片更换    

关注码农谷微信
专家推荐
老码农     向TA提问 最佳答案:67
冰点     向TA提问 最佳答案:28
itner     向TA提问 最佳答案:11
关于我们   |   免责声明   |   联系我们   |   网站地图   |   HR交流群   |   学生交流群   |   教师交流群

码农谷   版权所有 © 2015-2017   湘ICP备16018319号-1