import sys

N = int(eval(input()))

scores = [0]*(N*100+1)

scores[0] = 1



for _ in range(N):

    a = int(eval(input()))

    for i in reversed(list(range(len(scores)))):

        if scores[i]>0 and 0<i+a<=N*100:

            scores[i+a] += 1

            

for i in reversed(list(range(len(scores)))):

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

        print(i)

        sys.exit()

            

print((0))
N = int(eval(input()))

a = list(int(eval(input())) for _ in range(N))

a.sort()



ans = sum(a)

if ans%10 > 0:

    print(ans)

    exit()

for ai in a:

    if ai%10 > 0:

        print((ans - ai))

        break

else:

    print((0))

import sys

N = int(eval(input()))
scores = [0] * (N * 100 + 1)
scores[0] = 1
for _ in range(N):
    a = int(eval(input()))
    for i in reversed(list(range(len(scores)))):
        if scores[i] > 0 and 0 < i + a <= N * 100:
            scores[i + a] += 1
for i in reversed(list(range(len(scores)))):
    if scores[i] and i % 10 != 0:
        print(i)
        sys.exit()
print((0))

N = int(eval(input()))
a = list(int(eval(input())) for _ in range(N))
a.sort()
ans = sum(a)
if ans % 10 > 0:
    print(ans)
    exit()
for ai in a:
    if ai % 10 > 0:
        print((ans - ai))
        break
else:
    print((0))

-import sys - -scores = [0] * (N * 100 + 1) -scores[0] = 1 -for _ in range(N): -    a = int(eval(input())) -    for i in reversed(list(range(len(scores)))): -        if scores[i] > 0 and 0 < i + a <= N * 100: -            scores[i + a] += 1 -for i in reversed(list(range(len(scores)))): -    if scores[i] and i % 10 != 0: -        print(i) -        sys.exit() -print((0)) +a = list(int(eval(input())) for _ in range(N)) +a.sort() +ans = sum(a) +if ans % 10 > 0: +    print(ans) +    exit() +for ai in a: +    if ai % 10 > 0: +        print((ans - ai)) +        break +else: +    print((0))