#d1207. 拆方块
拆方块
Removing Blocks
Problem Description
There are piles of blocks; the -th pile is made of blocks stacked up (see the sample).
Now we remove blocks. A block is called an inner block if and only if its up, down, left and right neighbours are all blocks or the ground; otherwise it is a boundary block. In each operation we remove all boundary blocks.
Find after how many operations all blocks disappear.
Input Format
The first line contains an integer ().
The second line contains integers (), the number of blocks in each pile.
Output Format
Output the number of operations needed for all blocks to disappear.
Sample Input
6
2 1 4 6 2 2
Sample Output
3
Sample Explanation

Constraints
For all data, and .