int input maxx int input for in range n-1 int input if and maxx maxx m

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
n = int(input())
t = [0]*3
maxx = int(input())
for i in range(n-1):
x = int(input())
if x == 0 and maxx != 0 :
t[maxx%3] = maxx
maxx = 0
elif i == n-2 and x != 0:
t[x%3] = x
elif x > maxx : maxx = x
p = max(t[0],t[1]+t[2])
if p%3 != 0: p = t[0]
if p == 0: print('no')
else:print(p)