Back/Monotonic Stack: Array Total

Monotonic Stack: Array Total

EasyLevel: 7Topic: Stacks and Queues
XP Reward:+50 XPCoin Reward:+5 Coins

You are given a list of integers. Your task is to compute the total sum of all values in the list.

This problem is part of Stacks and Queues practice and is designed to strengthen the Monotonic Stack pattern.

Input Format

  • The first line contains an integer n, the number of values.
  • The second line contains n space-separated integers.

Output Format

Return one integer: the sum of the given values.

Example 1

Input:

7
-11 7 25 43 61 -18 0

Output:

107

Explanation:

  • The values are -11, 7, 25, 43, 61, -18, 0.
  • Adding them gives 107.

Constraints

  • 1 <= n <= 10^5
  • -10^9 <= value <= 10^9

Return Requirement

Implement the starter function for this Easy problem. Read from the raw input string and return only the required answer, with no labels or debug text.

Judge Behavior

Run Code checks the visible sample cases. Submit checks those samples plus additional hidden cases that follow the same input format and constraints.

Loading editor...
Input
7
-11 7 25 43 61 -18 0
Expected Output
107