Preparando MOJI
You have a multiset containing several integers. Initially, it contains $$$a_1$$$ elements equal to $$$1$$$, $$$a_2$$$ elements equal to $$$2$$$, ..., $$$a_n$$$ elements equal to $$$n$$$.
You may apply two types of operations:
What is the minimum number of operations required to delete all elements from the multiset?
The first line contains one integer $$$n$$$ ($$$1 \le n \le 5000$$$).
The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$0 \le a_i \le 10^9$$$).
Print one integer — the minimum number of operations required to delete all elements from the multiset.
4 1 4 1 1
2
5 1 0 1 0 1
3