Digit sum

You are given a list of numbers, and your task is to write a program that calculates the sum of the digits of each number in the list, and then returns the total sum of all the digits.
The first line of the input contains an integer n. The next n lines contain positive integers. Print the sum of the digits of all input numbers.
Input
Output
3 123 234 345
27
4 42 53 420 36
29
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue