#K36572. Sum of Numbers in an Iterable

    ID: 25784 Type: Default 1000ms 256MiB

Sum of Numbers in an Iterable

Sum of Numbers in an Iterable

This problem requires you to compute the sum of a series of numbers with an additional starting value. In other words, you need to mimic the behavior of the built-in sum function in Python.

If you have an iterable (or list) of numbers \(a_1, a_2, \ldots, a_n\) and an initial starting value \(s\), you are to compute the following:

[ sum = s + \sum_{i=1}^{n} a_i ]

Note that if the list is empty (i.e., \(n=0\)), the output should simply be the starting value \(s\). The output should be printed to standard output. If the resulting sum is an integer, print it without a decimal point; otherwise, output the numeric result in floating point format.

inputFormat

The input is read from standard input (stdin) and consists of three parts:

  • The first line contains an integer \(n\), representing the number of elements in the iterable.
  • The second line contains \(n\) space-separated numbers. If \(n = 0\), this line will be empty.
  • The third line contains a single number, which is the starting value \(s\) used in the summation.

It is guaranteed that all numbers are valid integers or floats.

outputFormat

Output the result of the summation to standard output (stdout). If the result is an integer, it should be printed without a decimal point; otherwise, print the floating point value.

## sample
3
1 2 3
0
6

</p>