TABS - Tabs

no tags 

Description

In many text editors, one or more consecutive lines can be selected. When they are selected, pressing the tab key will insert a tab at the beginning of each of the lines.
Given the desired indentation levels (i.e. number of leading tabs) of lines in a file, what is the fewest number of times the tab key must be pressed to reach that indentation level. The file begins without any indendation.
For example, if
for x in [1, 2, 3]:
for y in [1, 2, 3]:
z += x * y
print z
should be indented
for x in [1, 2, 3]:
	for y in [1, 2, 3]:
		z += x * y
	print z
then the answer is 2. The second, third, and fourth lines can be indented together. The third line is indented again, separately.

Input

The first line is the number of lines of text, 0 < N <= 5000.
The next N lines are integers from 0 to 80. These are the degree of indentation for each line.

Output

The minimum number of tab key presses required to perform the indentation.
Input
4
0
1
2
1
Output
2


Added by:BYU Admin
Date:2014-02-23
Time limit:1s-2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64