#CCBCHBON0000011. Summing Consecutive Integers (Summing Consecutive Integers)

Summing Consecutive Integers (Summing Consecutive Integers)

Summing Consecutive Integers

Source: beecrowd

Version: Phuoc Hung OJ Extended

Problem Statement

Read integer AA, then keep reading candidate values for NN until the first strictly positive value. Ignore zero and negative candidates. Print the sum of exactly NN consecutive integers beginning at AA inclusive.

Input

One line contains AA followed by 1 to 100 candidate values for NN; the final candidate is the first positive one. PHOJ bounds: −1000≤A≤1000-1000\le A\le1000, candidates in [−1000,1000][-1000,1000], accepted NN in [1,1000][1,1000].

Output

Print one integer, the requested sum.

Subtasks

  • Subtask 1 (20%): At most 3 nonpositive candidates before the first positive NN; 1≤N≤10001\le N\le1000.

  • Subtask 2 (30%): At most 15 nonpositive candidates before the first positive NN; 1≤N≤10001\le N\le1000.

  • Subtask 3 (50%): At most 100 nonpositive candidates before the first positive NN; 1≤N≤10001\le N\le1000.

Examples

Example 1

Input:

3 -2 0 2

Output:

7

Explanation:

Ignore nonpositive N candidates, then add exactly N integers starting from A.

Example 2

Input:

-3 0 -1 4

Output:

-6

Explanation:

Ignore nonpositive N candidates, then add exactly N integers starting from A.