Submit solution
Points:
3 (partial)
Time limit:
1.0s
Memory limit:
1G
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
Given a list of integers, compute the sum of the nonzero ones.
In the event the list contains no nonzero integers, the desired sum is zero.
Constraints
In tests worth 5 marks, all are nonzero.
Input Specification
The first line contains a single integer .
The next lines each contain a single integer,
, representing the
th integer in the list.
Output Specification
On a single line, output the sum of the nonzero integers.
Sample Input
10
0
0
0
0
0
0
0
0
0
0
Sample Output
0
Sample Input
2
1
-2
Sample Output
-1
Comments
A few questions: Why do we get 1G and what's the point of emphasizing non-zero Integers, even if you were to add them, it would't make a difference.
Ohhh I get it now, thanks for telling me