n = int(eval(input()))

a = [int(eval(input())) for _ in range(n)]

dp = [[] for _ in range(n+1)]

for i in range(n+1):

    dp[i] += [-1 for _ in range(10010)]

dp[0][0] = 1

for i in range(n):

    for j in range(10010):

        if dp[i][j] == 1:

            dp[i+1][j] = 1

            dp[i+1][j+a[i]] = 1

ans = 0

for i in range(10010):

    if dp[n][i] == 1:

        if i % 10 != 0:

            ans = max(ans,i)

print(ans)
n = int(eval(input()))

ary = [int(eval(input())) for _ in range(n)]

total = sum(ary)

ans = 0

if total % 10 != 0:

    print(total)

    exit()

for i in ary:

    a = total - i

    if a % 10 != 0:

        ans = max(ans,a)

print(ans)
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
dp = [[] for _ in range(n + 1)]
for i in range(n + 1):
    dp[i] += [-1 for _ in range(10010)]
dp[0][0] = 1
for i in range(n):
    for j in range(10010):
        if dp[i][j] == 1:
            dp[i + 1][j] = 1
            dp[i + 1][j + a[i]] = 1
ans = 0
for i in range(10010):
    if dp[n][i] == 1:
        if i % 10 != 0:
            ans = max(ans, i)
print(ans)

n = int(eval(input()))
ary = [int(eval(input())) for _ in range(n)]
total = sum(ary)
ans = 0
if total % 10 != 0:
    print(total)
    exit()
for i in ary:
    a = total - i
    if a % 10 != 0:
        ans = max(ans, a)
print(ans)

-a = [int(eval(input())) for _ in range(n)] -dp = [[] for _ in range(n + 1)] -for i in range(n + 1): -    dp[i] += [-1 for _ in range(10010)] -dp[0][0] = 1 -for i in range(n): -    for j in range(10010): -        if dp[i][j] == 1: -            dp[i + 1][j] = 1 -            dp[i + 1][j + a[i]] = 1 +ary = [int(eval(input())) for _ in range(n)] +total = sum(ary) -for i in range(10010): -    if dp[n][i] == 1: -        if i % 10 != 0: -            ans = max(ans, i) +if total % 10 != 0: +    print(total) +    exit() +for i in ary: +    a = total - i +    if a % 10 != 0: +        ans = max(ans, a)