Raees's Liquor Tank
Tag(s):

## Easy

Problem
Editorial
Analytics

Raees wants to build a new tank to hide his illegal liquor . He comes up with some designs . Now he asks you to find out maximum units of liquor he can fill in the tank.

You are given N elements , corresponding to heights of walls . See the figure for input 0 ,8 ,0 ,4 ,0 ,3 ,0 ,5 ,0 ,3 ,0 ,1 ,0.

Maximum amount of liquor that can be filled is 5 + 1 + 5 + 2 + 5 + 3 + 1 = 22.

Eg : For input 4 ,2 ,4 ,3 Output will be 2 .

INPUT

• First line of input contains a single integer N.
• Second line of input contains N non-negative integers ( A0 --- A(n-1) ).

OUTPUT

• Single integer , answer to the Raees's question.

CONSTRAINTS

• 1 <= N <= 1000
• 1 <= Ai <= 1000
SAMPLE INPUT
13
0 8 0 4 0 3 0 5 0 3 0 1 0
SAMPLE OUTPUT
22
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

## CODE EDITOR

Initializing Code Editor...
Your Rating:

## This Problem was Asked in

Challenge Name

MNIT-Codes Episode-01

OTHER PROBLEMS OF THIS CHALLENGE
• Math > Number Theory
• Math > Polygon
• Math > Number Theory
Notifications

?