int input input for in range join split for in range len max list map

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
n = int(input())
t = [0]*3
a = [input() for i in range(n)]
a = ''.join(a).split('0')
for i in range(len(a)):
x = max(list(map(int,a[i])))
t[x%3] = x
if t[0] == 0 and (t[1]+t[2])%3 != 0:print('no')
elif max(t[0],t[1]+t[2])%3 == 0: print(max(t[0],t[1]+t[2]))
else:print(t[0])