SP7600 MLK - Milk Trading

Description

Hareedi and Hanadt live in a village with **N** houses built next to each other along one straight roadway with equal distances between adjacent houses. Some people own cows and sell the milk their cows produce, while others do not own cows and may need to buy milk. Every morning, Hareedi and Hanadi transport milk around the village such that everyone buys or sells the exact number of bottles they want. Transporting one bottle of milk from one house to an adjacent house results in one unit of work. **Fortunately**, the number of milk bottles needed by people is always equal to the number of milk bottles sold by cow owners. ### Task write a program that is given the number of milk bottles that people at each house needs to buy or sell, represented as an integer, finds the minimum work necessary to transport the bottles from sellers to buyers. **Constraints** 2 N -1000 ****B $ _{i} $ **1000** Integer representing the number of bottles to be bought from or**** sold to people at the house at position **i.** **Input** - Line 1 contains the integer **N**, the number of houses. - Each of the next **N** lines contains an integer **B $ _{i} $ . If **B $ _{i} $** > 0 then people in house i are cow** owners and want **to sell **B $ _{i} $** bottles of milk, If **B $ _{i} $** i are not cow owners** **and want to buy **B $ _{i} $** bottles of milk.** **Output** - A single line containing a single integer, the minimum work units necessary to transport the bottle of milk.

Input Format

N/A

Output Format

N/A