Source Code
while True:
    n = int(input())
    if n >=1 and n<=10**5:
        break
lst = []
l = (input())
l = l.split(" ")
sm = 0

for i in range (len(l)):
    sm += int(l[i])

if sm < 10:
    print (sm)
else:
    while True:
        x = str(sm)
        sm = 0
        for i in range (len(x)):
            sm += int(x[i])
        if sm < 10:
            print (sm)
            break
Copy
The Tale of a Generous Prince massoud01
Python 3
78 ms
14.1 MB
Accepted