N = int(eval(input()))

nums=[int(eval(input())) for _ in range(N)]

sum_num = sum(nums)

dp = [0] * (sum_num+1)

dp[0] = 1

for num in nums:

  for i in range(sum_num+1)[::-1]:

    if dp[i] == 1 and i + num <= sum_num:

      dp[i+num] = 1

ans = 0

for i in range(sum_num+1):

  if dp[i] == 1 and i%10 != 0:

    ans = i

print(ans)

N = int(eval(input()))

nums=[int(eval(input())) for _ in range(N)]

sum_num = sum(nums)

dp = [0] * (sum_num+1)

dp[0] = 1

for num in nums:

  for i in range(sum_num+1)[::-1]:

    if dp[i] == 1:

      dp[i+num] = 1

ans = 0

for i in range(sum_num+1):

  if dp[i] == 1 and i%10 != 0:

    ans = i

print(ans)

N = int(eval(input()))
nums = [int(eval(input())) for _ in range(N)]
sum_num = sum(nums)
dp = [0] * (sum_num + 1)
dp[0] = 1
for num in nums:
    for i in range(sum_num + 1)[::-1]:
        if dp[i] == 1 and i + num <= sum_num:
            dp[i + num] = 1
ans = 0
for i in range(sum_num + 1):
    if dp[i] == 1 and i % 10 != 0:
        ans = i
print(ans)

N = int(eval(input()))
nums = [int(eval(input())) for _ in range(N)]
sum_num = sum(nums)
dp = [0] * (sum_num + 1)
dp[0] = 1
for num in nums:
    for i in range(sum_num + 1)[::-1]:
        if dp[i] == 1:
            dp[i + num] = 1
ans = 0
for i in range(sum_num + 1):
    if dp[i] == 1 and i % 10 != 0:
        ans = i
print(ans)

-        if dp[i] == 1 and i + num <= sum_num: +        if dp[i] == 1: