N = int(eval(input()))

maxs = 0    

s = []

for i in range(N):

    cin = int(eval(input()))

    s.append(cin)

    maxs = max(maxs, cin)

M = maxs * N



dp = [False] * (M+1)

dp[0] = True



for x in s:

    for i in range(M+1):

        if M-i < x: continue

        if dp[M-i-x]: dp[M-i] = True



for i in range(M+1):

    if (M-i)%10 != 0 and dp[M-i]:

        print((M-i))

        break

else:

    print((0)) 
with open(0) as f:

    N,  *S = list(map(int, f.read().split()))

Score = [True if i == 0 else False for i in range(10000)]

for s in S:

    for i in reversed(list(range(s, 10000))):

        if Score[i-s]:

            Score[i] = True



for i in reversed(list(range(10000))):

    if Score[i] and i % 10 != 0:

        print(i)

        break

else:

    print((0))
N = int(eval(input()))
maxs = 0
s = []
for i in range(N):
    cin = int(eval(input()))
    s.append(cin)
    maxs = max(maxs, cin)
M = maxs * N
dp = [False] * (M + 1)
dp[0] = True
for x in s:
    for i in range(M + 1):
        if M - i < x:
            continue
        if dp[M - i - x]:
            dp[M - i] = True
for i in range(M + 1):
    if (M - i) % 10 != 0 and dp[M - i]:
        print((M - i))
        break
else:
    print((0))

with open(0) as f:
    N, *S = list(map(int, f.read().split()))
Score = [True if i == 0 else False for i in range(10000)]
for s in S:
    for i in reversed(list(range(s, 10000))):
        if Score[i - s]:
            Score[i] = True
for i in reversed(list(range(10000))):
    if Score[i] and i % 10 != 0:
        print(i)
        break
else:
    print((0))

-N = int(eval(input())) -maxs = 0 -s = [] -for i in range(N): -    cin = int(eval(input())) -    s.append(cin) -    maxs = max(maxs, cin) -M = maxs * N -dp = [False] * (M + 1) -dp[0] = True -for x in s: -    for i in range(M + 1): -        if M - i < x: -            continue -        if dp[M - i - x]: -            dp[M - i] = True -for i in range(M + 1): -    if (M - i) % 10 != 0 and dp[M - i]: -        print((M - i)) +with open(0) as f: +    N, *S = list(map(int, f.read().split())) +Score = [True if i == 0 else False for i in range(10000)] +for s in S: +    for i in reversed(list(range(s, 10000))): +        if Score[i - s]: +            Score[i] = True +for i in reversed(list(range(10000))): +    if Score[i] and i % 10 != 0: +        print(i)