int input ch1 ch2 maxs ost for in range int input y1 if if ost y1 maxs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
n = int(input())
ch1 = 0
ch2 = 0
maxs = 0
ost = [0, 0] * 5
for i in range(n):
x = int(input())
y = x%5; y1 = (5 - y)%5
if x % 2 == 0:
if x + ost[y1][0] > maxs and ost[y1][0] != 0:
ch1 = ost[y1][0]
ch2 = x
maxs = ch1 + ch2
if x > ost[y][0]:
ost[y][0] = x
else:
if x + ost[y1][1] > maxs and ost[y1][1] != 0:
ch1 = ost[y1][1]
ch2 = x
maxs = ch1 + ch2
if x > ost[y][1]:
ost[y][1] = x
print(ch1, ch2)