#PS0000104. Hàng rào (Fence)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Hàng rào (Fence)
Fence
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Polycarpus has a fence in front of his house consisting of equal-width planks in a row. Plank has height metres. To move a piano inside, he must remove exactly consecutive planks. Since taller planks are harder to remove, he wants the minimum possible total height of the chosen planks. The fence is not circular. Find a starting position attaining that minimum.

Input
The first line contains integers .
The second line contains integers , the heights from left to right.
Output
Print one integer () minimizing . If several positions attain the minimum, any of them is accepted.
Subtasks
- Subtask 1 (20 points): ; ; for all .
- Subtask 2 (30 points): ; ; for all .
- Subtask 3 (50 points): ; ; for all .
Examples
Input
7 3
1 2 6 1 1 7 1
Output
3
Explanation
Exactly three consecutive planks must be removed. The totals for starts 1, 2, 3, 4, 5 are . Starting at 3 removes heights metres, attaining the minimum 8.