#C13282. Cumulative Sum Above Threshold

    ID: 42803 Type: Default 1000ms 256MiB

Cumulative Sum Above Threshold

Cumulative Sum Above Threshold

Given an array of integers and a threshold value \(T\), calculate the cumulative sum of all elements that are strictly greater than \(T\). The program should read input through stdin and output the result to stdout.

The input format is as follows:

  • The first line contains two space-separated integers: the threshold \(T\) and the number of elements \(N\) in the array.
  • If \(N > 0\), the second line contains \(N\) space-separated integers representing the elements of the array.

Your task is to compute and print the sum of all numbers in the array that are greater than \(T\). If no elements exceed \(T\), output 0.

inputFormat

The input is read from stdin and consists of two parts:

  • Line 1: Two integers \(T\) (the threshold) and \(N\) (the number of array elements), separated by a space.
  • Line 2 (only if \(N > 0\)): \(N\) space-separated integers representing the array elements.

outputFormat

Output to stdout a single integer: the cumulative sum of all array elements that are strictly greater than \(T\). If no such elements exist, output 0.

## sample
5 3
10 20 30
60