Cricket Rating
Tag(s):

Problem
Editorial
Analytics

India is a cricket crazy nation. Chang also loves cricket and computations related to cricket. Chang has created a Cricket app.This app analyses the performance of a cricketer. If a cricketer under-performs, then a negative rating is awarded. If performance is good, then positive rating is awarded to the cricketer.Chang wants to analyse the performance of a cricketer over a period of N matches. Chang wants to find consistency of a cricketer. So he wants to find out the maximum consistent sum of cricket rating of a batsman or a bowler only if his overall rating is positive over that period. Help chang in doing so.

Input

The first line contain number of matches "N" over which the analysis is to be done. The second line contains those ratings of a batsman/bowler in those N matches.

Output

Print a single integer ie. the maximum consistent sum of rating of the cricketer if it is positive otherwise output 0 (zero).

Constraint

$0 \le N(matches) \le 10^5$

$-100 \le rating \le +100$

SAMPLE INPUT
8
-1 -4  4 -2 0 1 4 -5

SAMPLE OUTPUT
7

Explanation

here the maximum consistent and continuous sum of rating is $4 + (-2) + 0 + 1 + 4 = 7$

Time Limit: 3,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: Bash, 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, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

CommonFloor Backend Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Dynamic Programming
• Algorithms > Sorting
Уведомления

?