#CCBCHBA0000050. Police Recruits (Police Recruits)

Police Recruits (Police Recruits)

Police Recruits

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Start with zero available officers. Positive events recruit x officers, while -1 denotes a crime that consumes one available officer or remains untreated.

Input

1<=n<=100000; n events each -1 or an integer in [1,10].

Output

Number of untreated crimes.

Subtasks

  • Subtask 1 (20%): n<=5, số tuyển mỗi đợt <=3.
  • Subtask 2 (30%): n<=100, số tuyển <=6.
  • Subtask 3 (50%): n<=100000, số tuyển <=10.

Examples

Example 1

Input

3
-1 -1 1

Output

2

Explanation

The first two crimes are untreated.

Example 2

Input

8
1 -1 1 -1 -1 1 1 1

Output

1

Explanation

The third crime occurs with no officer available.