#C7924. Sum of Multiples
Sum of Multiples
Sum of Multiples
You are given an array of integers and a limit integer (n). Your task is to compute the sum of all numbers in the array that are less than (n) and are multiples of either 3 or 5.
Formally, for an array (A) of size (T) and an integer (n), you have to find (\sum_{x \in A,\ x < n \ \text{and} \ (x \bmod 3 = 0 \ \text{or} \ x \bmod 5 = 0)} x).
Ensure that you read the input from standard input (stdin) and write the output to standard output (stdout). This is a straightforward problem designed to test your ability to filter and sum elements based on given conditions.
inputFormat
The input is read from standard input.
The first line contains an integer (T) which denotes the number of elements in the array.
The second line contains (T) space-separated integers representing the array (A).
The third line contains an integer (n), the upper limit.
It is guaranteed that (T \ge 0) and all numbers are integers.
outputFormat
Output a single integer, which is the sum of all numbers in the array that are less than (n) and are divisible by 3 or 5. The output should be written to standard output.## sample
5
2 3 5 7 8
10
8