n=int(eval(input()))

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

ans=0

a.sort()

for i in range(n):

    if sum(a)%10 == 0:

        if a[i]%10 == 0:

            pass

        else:

            a[i]=0

    else:

        print((sum(a)))

        exit(0)

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

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

a.sort()

for i in range(n):

    if sum(a)%10 == 0:

        if a[i]%10 == 0:

            continue

        else:

            a[i]=0

    else:

        print((sum(a)))

        exit(0)

print((0))
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
ans = 0
a.sort()
for i in range(n):
    if sum(a) % 10 == 0:
        if a[i] % 10 == 0:
            pass
        else:
            a[i] = 0
    else:
        print((sum(a)))
        exit(0)
print((0))

n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
a.sort()
for i in range(n):
    if sum(a) % 10 == 0:
        if a[i] % 10 == 0:
            continue
        else:
            a[i] = 0
    else:
        print((sum(a)))
        exit(0)
print((0))

-ans = 0 -            pass +            continue