CodeEff/ECCO huggingface dataset:
# Original solution
def main():
    N = int(eval(input()))
    S = []
    for _ in range(N):
        S.append(int(eval(input())))
    
    maxScore = 0
    for i in range(2 ** N):
        tmp = 0
        for j in range(N):
            if ((i >> j) & 1):
                tmp = tmp + S[j]
        if tmp % 10 == 0:
            tmp = 0
        if maxScore < tmp:
            maxScore = tmp
    
    print(maxScore)


if __name__ == "__main__":
    main()

# Optimized solution
def main():
    N = int(eval(input()))
    S = []
    M = []
    sumsum = 0
    for _ in range(N):
        t = int(eval(input()))
        if t != 0:
            sumsum = sumsum + t
            S.append(t)
            if t % 10 != 0:
                M.append(t)

    if sumsum % 10 != 0:
        print(sumsum)
        return
    
    if len(M) == 0:
        print("0")
        return

    M.sort()
    print((sumsum - M[0]))


if __name__ == "__main__":
    main()
# Original solution
import itertools

n = int(eval(input()))
s = [int(eval(input())) for s in range(n)]
max0 = 0
for i in range(n):
    s2 = list(itertools.permutations(s, i+1))
    for comb in s2:
        tmax =sum(comb)
        if tmax%10 != 0: 
            max0 = max(max0,sum(comb))
print(max0)

# Optimized solution
n = int(eval(input()))
s = [int(eval(input())) for s in range(n)]
s1 = []
sum0 = 0
for i in s:
    if i%10 == 0:
        sum0 += i
    else:
        s1.append(i)

if len(s1) == 0:
    print((0))
else:
    sum1 = sum(s1)
    if sum1%10 != 0:
        print((sum0 + sum1))
    else:
        print((sum0 + sum1 - min(s1)))
# Original solution
n=int(eval(input()))

score=[]
ans=0

for _ in range(n):
    s=int(eval(input()))
    score.append(s)

# if score%10==0:
#     ans=0

# score=sorted(score,reverse=True)
# for _ in range(n):
#     score.pop()
#     tmp=sum(score)
#     if tmp%10==0:
#         tmp=0

#     ans=max(ans,tmp)

from itertools import combinations 

for m in range(1,n+1):
    c=combinations(score,m)

    for i in c:
        tmp=sum(i)
        if tmp%10==0:
            tmp=0

        ans=max(ans,tmp)

print(ans)
    

# Optimized solution
n=int(eval(input()))

score=[]
for _ in range(n):
    s=int(eval(input()))
    score.append(s)

#すべて10の倍数ならば0である
non10=[]
flg10=0
for i in range(n):
    if score[i]%10!=0:
        non10.append(score[i])
        flg10=1
    
if flg10==0:
    ans=0
else:
    if sum(score)%10==0:
        ans=sum(score)-min(non10)
    else:
        ans=sum(score)
print(ans)
# Original solution
n = int(eval(input()))
S = []
for i in range(n):
    S.append(int(eval(input())))
ans = []
import itertools
for i in itertools.product(list(range(2)), repeat=n):
    scr = 0
    for j in range(n):
        if i[j]:
            scr += S[j]
    if scr%10 == 0:
        scr = 0
    ans.append(scr)
print((max(ans)))

# Optimized solution
n = int(eval(input()))
S = sorted([int(eval(input())) for _ in range(n)])

if sum(S)%10!=0:
    print((sum(S)))
    exit()
for i in range(n):
    if S[i]%10==0:
        continue
    print((sum(S)-S[i]))
    exit()
print((0))
# Original solution
N = int(eval(input()))

S = []

for _ in range(N):
    s = int(eval(input()))
    S.append(s)

max = 0
for i in range(s**N):
    L = [1]*N
    sum = 0
    for j in range(N):
        if (i>>j)&1:
            L[j] = 0
    for k in range(N):
        if L[k]==1:
            sum = sum + S[k]
    if max < sum and sum%10!=0:
        max = sum
print(max)

# Optimized solution
N = int(eval(input()))

S = []

for _ in range(N):
    s = int(eval(input()))
    S.append(s)

max = sum(S)

if max%10!=0:
    print(max)
else:
    min = float('inf')
    for i in range(N):
        if S[i]<min and S[i]%10!=0:
            min = S[i]
    if min==float('inf'):
        print((0))
    else:
        print((max-min))
# Original solution
n = int(eval(input()))
s = [0] * n
for i in range(n):
    s[i] = int(eval(input()))

ans = 0
for i in range(2 ** n):
    score = 0
    for j in range(n):
        if i >> j & 1:
            score += s[j]
        
    if score % 10 != 0:
        ans = max(ans, score)

print(ans)



# Optimized solution
n = int(eval(input()))
s = [0] * n
for i in range(n):
    s[i] = int(eval(input()))

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    s.sort()
    for i in range(n):
        if s[i] % 10 != 0:
            print((ans - s[i]))
            exit()
        
    print((0))
# Original solution
n = int(eval(input()))
s = [int(eval(input())) for _ in range(n)]
dp = [[-1 for _ in range(n*100+1)] for _ in range(n+1)]
dp [0][0] = 0
for i in range(n):
    for j in range(n*100+1):
        if dp[i][j] != -1:
            dp[i+1][j] = dp[i][j]
            dp[i+1][j+s[i]] = dp[i][j] + s[i]
res = 0
for i in range(n*100+1)[::-1]:
    if dp[n][i] > res and i % 10 != 0:
        res = dp[n][i]
        break
print(res)


# Optimized solution
n = int(eval(input()))
s = [int(eval(input())) for _ in range(n)]
dp = [[-1 for _ in range(sum(s)+1)] for _ in range(n+1)]
dp [0][0] = 0
for i in range(n):
    for j in range(sum(s)+1):
        if dp[i][j] != -1:
            dp[i+1][j] = dp[i][j]
            dp[i+1][j+s[i]] = dp[i][j] + s[i]
res = 0
for i in range(sum(s)+1)[::-1]:
    if dp[n][i] > res and i % 10 != 0:
        res = dp[n][i]
        break
print(res)
# Original solution
N = int(eval(input()))
s = []
for i in range(N):
    s.append(int(eval(input())))
s.sort()
ssum = sum(s)
dp = [[-(10**5) for i in range(ssum+1)] for j in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for j in range(ssum+1):
        if j-s[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-s[i-1]]+s[i-1])
        else:
            dp[i][j] = dp[i-1][j]

maxa = 0
for j in range(N+1):
    for i in range(ssum+1):
        if (dp[j][i])%10 == 0:
            continue
        else:
            now = dp[j][i]
            maxa = max(maxa,now)

print(maxa)

# Optimized solution
N = int(eval(input()))
s = []
for i in range(N):
    s.append(int(eval(input())))

ssum = sum(s)
dp = [[-(10**5) for i in range(ssum+1)] for j in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for j in range(ssum+1):
        if j-s[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-s[i-1]]+s[i-1])
        else:
            dp[i][j] = dp[i-1][j]

maxa = 0
for j in range(N+1):
    for i in range(ssum+1):
        if (dp[j][i])%10 == 0:
            continue
        else:
            now = dp[j][i]
            maxa = max(maxa,now)

print(maxa)
# Original solution
N = int(eval(input()))
s = []
for i in range(N):
    s.append(int(eval(input())))

ssum = sum(s)
dp = [[-(10**5) for i in range(ssum+1)] for j in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for j in range(ssum+1):
        if j-s[i-1] >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-s[i-1]]+s[i-1])
        else:
            dp[i][j] = dp[i-1][j]

maxa = 0
for j in range(N+1):
    for i in range(ssum+1):
        if (dp[j][i])%10 == 0:
            continue
        else:
            now = dp[j][i]
            maxa = max(maxa,now)

print(maxa)

# Optimized solution
N = int(eval(input()))
s = []
for i in range(N):
    s.append(int(eval(input())))
s.sort()
ssum = sum(s)
c = 0
for i in s:
    if ssum%10 != 0:
        print(ssum)
        c = 1
        break
    if i%10 != 0:
        ssum -= i
if c == 0:
    print((0))
# Original solution
n = int(eval(input()))

A = []
for i in range(n):
    A.append(int(eval(input())))

import itertools
B = []
for i in range(n+1):
    for j in itertools.permutations(A, i):
        sum_ = sum(j)
        if sum_ % 10 == 0:
            B.append(0)
        else:
            B.append(sum_)
print((max(B)))

# Optimized solution
n = int(eval(input()))

A = []
for i in range(n):
    A.append(int(eval(input())))
total = sum(A)

if total % 10 != 0:
    print(total)
else:
    A = sorted(A)
    for i in range(n):
        if A[i] % 10 != 0:
            total -=A[i]
            break
    if total % 10 == 0:
        print((0))
    else:
        print(total)
# Original solution
n = int(eval(input()))
s = [int(eval(input())) for i in range(n)]

ans = []
for i in range(1<<n):
    x = 0
    for j in range(n):
        if (i>>j) & 1:
            x += s[j]
    if x % 10 == 0:
        ans.append(0)
    else:
        ans.append(x)

print((max(ans)))

# Optimized solution
n = int(eval(input()))
s = [int(eval(input())) for i in range(n)]

sum_s = sum(s)
if sum_s % 10 != 0:
    print(sum_s)
    exit()

if all([1 if x % 10 == 0 else 0 for x in s]):
    print((0))
else:
    for i in range(n):
        if s[i] % 10 == 0:
            s[i] = 101
    s.sort()
    ans = sum_s - s[0]
    print(ans)
# Original solution
def main():
    N = int(eval(input()))
    s = [int(eval(input())) for _ in range(N)]

    dp = [False] * (10000 + 1)
    dp[0] = True

    for x in s:
        for score in range(10000 - x, -1, -1):
            dp[score + x] |= dp[score]

    for score in range(10000, -1, -1):
        if dp[score] and score % 10 != 0:
            print(score)
            return
    print((0))


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


# Optimized solution
def main():
    N = int(eval(input()))
    s = [int(eval(input())) for _ in range(N)]

    tot = sum(s)

    if tot % 10 == 0:
        s.sort()
        for x in s:
            if x % 10 == 0: continue
            tot -= x
            break
        else:
            tot = 0
    print(tot)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
# Original solution
def get_sum(n, index, s, slist):
    if index == n:
        if s % 10 == 0:
            s = 0
        return s
    left = get_sum(n, index + 1, s + slist[index], slist)
    right = get_sum(n, index + 1, s, slist)
    return max(left, right)


N = int(eval(input()))
sl = []
for n in range(N):
    sl.append(int(eval(input())))

sum = 0
index = 0
for s in sorted(sl)[::-1]:
    if (sum + s) % 10 == 0:
        break
    sum += s
    index += 1

print((get_sum(N, index, sum, sl)))

# Optimized solution
N = int(eval(input()))
sl = []
for n in range(N):
    sl.append(int(eval(input())))

sum = sum(sl)
sorted_sl = sorted([s for s in sl if s % 10 != 0])
if len(sorted_sl) == 0:
    print((0))
    exit()
count = 0
while sum % 10 == 0 and count < len(sorted_sl):
    sum -= sorted_sl[count]
    count += 1

print(sum)
# Original solution
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    s = []
    for i in range(N):
        s.append(int(input().rstrip()))
    dp = []
    for i in range(N):
        dp.append([-1]*(100*100))
    dp[0][s[0]] = 1
    for i in range(1,N):
        for j in range(100*100):
            if(j == s[i] or (j-s[i]>=0 and dp[i-1][j-s[i]]==1)):
                dp[i][j] = 1
            else:
                dp[i][j] = dp[i-1][j]
    ans = 0
    # print('\n'.join(str(_) for _ in(dp[N-1])))
    for i in range(100*100-1,0,-1):
        if(i%10 != 0 and dp[N-1][i]==1):
            ans = i
            break
    print(ans)
if __name__ == '__main__':
    main()


# Optimized solution
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    s = []
    for i in range(N):
        s.append(int(input().rstrip()))
    s.sort()
    ans = 0
    
    if sum(s) % 10 != 0:
        ans = sum(s)
        print(ans)
        exit()
    for i in range(N):
        if(s[i]%10 !=0 ):
            ans = sum(s) - s[i]
            break
    # dp = []
    # for i in range(N):
    #     dp.append([-1]*(100*100))
    # dp[0][s[0]] = 1
    # for i in range(1,N):
    #     for j in range(100*100):
    #         if(j == s[i] or (j-s[i]>=0 and dp[i-1][j-s[i]]==1)):
    #             dp[i][j] = 1
    #         else:
    #             dp[i][j] = dp[i-1][j]
    # ans = 0
    # for i in range(100*100-1,0,-1):
    #     if(i%10 != 0 and dp[N-1][i]==1):
    #         ans = i
    #         break
    print(ans)
if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]

ans = -1
for i in range(2**n):
    cnt = 0
    for j in range(n):
        if i >> j & 1:
            cnt += a[j]
    if cnt % 10 == 0:
        cnt = 0
    ans= max(ans, cnt)
print(ans)

# Optimized solution
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()

ans = sum(a)
if ans % 10 != 0:
    print(ans)
    exit()
    
flg = False
for i in range(n):
    if a[i] % 10 != 0:
        ans -= a[i]
        flg = True
        break
print(ans) if flg else print(0)
# Original solution
from itertools import product
N = int(eval(input()))
s = [int(eval(input())) for _ in range(N)]
a = list(product(list(range(2)),repeat = N))
s.sort(reverse=True)
while len(s) >0 and sum(s)%10==0:
  s.pop()
print((sum(s)))

# Optimized solution
N = int(eval(input()))
s = sorted([int(eval(input())) for _ in range(N)])

if sum(s)%10 != 0:
  print((sum(s)))
else:
  for i in range(N):
    if s[i] %10 != 0:
      print((sum(s)-s[i]))
      exit()
  print((0))
# Original solution
N = int(eval(input()))
S = []
for i in range(N):
    S.append(int(eval(input())))

hasFinished = False

ans_cand = []
def dfs(cp, length):
    
    if length == N:
        if cp%10 != 0:
            print(cp)
            exit()
            
    else:
        dfs(cp+S[length], length+1)
        dfs(cp, length+1)
        
def ten2zero(num):
    if num%10==0:
        return 0
    else:
        return num        

def solve(N,S):
    S.sort(reverse=True)
    s_per5 = [s%10 for s in S]
    
    if sum(s_per5)==0:
        print((0))
        return
    
    else:    
        return dfs(0,0)

solve(N,S)

# Optimized solution
N = int(eval(input()))
S = []
for i in range(N):
    S.append(int(eval(input())))

total = sum(S)

if total%10 == 0:
    
    new_S = []
    for s in S:
        if s%10==0:
            new_S.append(101)
        else:
            new_S.append(s)
    
        if sum(new_S) == 101*len(S):
            min_s = total
        else:
            min_s = min(new_S)
    
    print((total-min_s))
else:
    print(total)
# Original solution
from collections import Counter

n = int(eval(input()))
s = []
for _ in range(n):
    s.append(int(eval(input())))
    
cnt = Counter([0, s[0]])

if len(s) > 1:
    for si in s[1:]:
        tmp = Counter([])
        for k,v in list(cnt.items()):
            tmp[k + si] = v
            
        cnt += tmp

key_list = sorted(list(cnt.keys()), reverse=True)

for k in key_list:
    if k == 0:
        print(k)
        break
    
    elif k%10 == 0:
        continue
    
    print(k)
    break

# Optimized solution
n = int(eval(input()))
s = []
for _ in range(n):
    s.append(int(eval(input())))

total = sum(s)

if total % 10 != 0:
    print(total)

else:
    s.sort()    
    min_s = total
    
    for si in s:
        if si % 10 != 0:
            min_s = si
            break
        
    print((total - min_s))
# Original solution
from collections import deque

N = int(eval(input()))

S = []
for _ in range(N):
    S.append(int(eval(input())))

Q = deque([(0, 0)])

R = 0
while Q:
    i, pt = Q.popleft()
    if i == N and pt % 10 != 0:
        R = max(pt, R)
    if i < N:
        Q.append((i + 1, pt + S[i]))
        Q.append((i + 1, pt))

print(R)
    


# Optimized solution
from collections import deque

N = int(eval(input()))

S = []
for _ in range(N):
    S.append(int(eval(input())))

SA = sum(S)

if SA % 10 == 0:
    SS = [s for s in S if s % 10 != 0]
    if len(SS) > 0:
        SA -= min(SS)
    else:
        SA = 0

print(SA)
# Original solution
n = int(eval(input()))
A = [int(eval(input())) for i in range(n)]
maxv = 0

def f(q, p):
	global maxv
	if q == n:
		if p % 10 != 0 and p > maxv:
			maxv = p
		return
	f(q + 1, p + A[q])
	f(q + 1, p)

f(0, 0)
print(maxv)

# Optimized solution
n = int(eval(input()))
A = [int(eval(input())) for i in range(n)]
s = sum(A)
if s % 10:
	print(s)
else:
	A.sort()
	for a in A:
		if a % 10:
			print((s - a))
			exit()
	else:
		print((0))
# Original solution
def solve():
    N = int(eval(input()))
    s = [int(eval(input())) for _ in range(N)]
    s.sort()
    ans = sum(s)

    if ans % 10 != 0:
        print(ans)
        return

    mn = float('inf')
    for i in range(N):
        if s[i] % 10 != 0:
            mn = min(mn, s[i])
    
    if mn == float('inf'):
        print((0))
    else:
        ans -= mn
        print(ans)

if __name__ == '__main__':
    solve()

# Optimized solution
def solve():
    N = int(eval(input()))
    s = [int(eval(input())) for _ in range(N)]
    sm = sum(s)
    dp = [False] * (sm + 1)
    dp[0] = True

    for val in s:
        for i in range(sm, -1, -1):
            if dp[i] and i+val <= sm:
                dp[i+val] = True
    
    for i in range(sm, -1, -1):
        if dp[i] and i % 10 != 0:
            print(i)
            return
    else:
        print((0))

if __name__ == '__main__':
    solve()
# Original solution
N = int(eval(input()))
S = []
for i in range(N):
    S.append(int(eval(input())))
    
ans = 0
for bits in range(1 << N):
    check = 0
    for i in range(N):
        if (bits >> i & 1) == 1:
            check += S[i]
    if check % 10 != 0:
        ans = max(check,ans)
print(ans)

# Optimized solution
N = int(eval(input()))
S = []
for i in range(N):
    S.append(int(eval(input())))
    
S = sorted(S)
# print(S)

sum_S = sum(S)

if sum_S % 10 != 0:
    print(sum_S)
else:
    for i in range(N):
        if S[i] % 10 != 0:
            sum_S -= S[i]
            break
    if sum_S % 10 != 0:
        print(sum_S)
    else:
        print((0))
# Original solution
N = int(eval(input()))

A=[]
for i in range(N):
    A.append(int(eval(input())))

B = []
for i in range(2**N):
    gokei = 0
    for j in range(N):
        if ((i >> j) & 1):
            gokei += A[j]
    B.append(gokei)

B.sort(reverse=True)

for i in B:
    if i%10 != 0:
        print(i)
        break
else:
    print((0))

# Optimized solution
N = int(eval(input()))

A=[]
for i in range(N):
    A.append(int(eval(input())))

A.sort()

gokei = sum(A)

if gokei%10 != 0:
    print(gokei)
else:
    for i in range(N):
        if (gokei - A[i])%10 != 0:
            print((gokei - A[i]))
            break
    else:
        print((0))
# Original solution
n = int(eval(input()))
s = [int(eval(input())) for _ in range(n)]


# total:累計, i:index
def dfs(total, i):
    if i == n:
        if total % 10 != 0:
            return total
        else:
            return 0
    return max(dfs(total, i + 1), dfs(total + s[i], i + 1))


print((dfs(0, 0)))


# Optimized solution
n = int(eval(input()))
s = [int(eval(input())) for _ in range(n)]

total = sum(s)
s.sort()
if total % 10 != 0:
    print(total)
else:
    for i in range(n):
        if (total - s[i]) % 10 != 0:
            print((total - s[i]))
            exit()
    print((0))
# Original solution
n  = int(eval(input()))
s = [int(eval(input())) for i in range(n)]


ans = 0
for i in range(0,2**n):
    bits = (bin(i)[2:]).zfill(n)
    tmp = sum([j * int(k) for j, k in zip(s, bits)])
    ans = max(ans, tmp if tmp % 10 != 0 else 0)

print(ans)

# Optimized solution
n  = int(eval(input()))
s = [int(eval(input())) for i in range(n)]

s.sort()
ans = sum(s)
if (ans % 10 != 0):
    print(ans)
else:
    for i in s:
        if (i % 10 != 0):
            print((ans - i))
            break
    else:
        print((0))
# Original solution
import sys
sys.setrecursionlimit(1000000)

N = int(eval(input()))
s = [int(eval(input())) for i in range(N)]

def dfs(seq):
    if len(seq) == N:
        score = 0
        for i in range(N):
            if seq[i] == "1":
                score += s[i]
        if score % 10 == 0:
            return 0
        else:
            return score

    else:
        return max(dfs(seq + "0"), dfs(seq + "1"))

print((dfs("")))

# Optimized solution
import sys
sys.setrecursionlimit(1000000)

N = int(eval(input()))
s = [int(eval(input())) for i in range(N)]
wa = sum(s)
s.sort()
if wa % 10 != 0:
    print(wa)
else:
    for i in range(N):
        if s[i] % 10 != 0:
            print((wa - s[i]))
            break
    else:
        print((0))
# Original solution
N = int(eval(input()))
S = sorted([int(eval(input())) for _ in range(N)])
if all([s % 10 == 0 for s in S]):
    print((0))

for i in range(1 << N):
    s = sum(S)
    for j in range(N):
        if i & 1 << j:
            s -= S[j]
    # print(bin(i), s)
    if s % 10 != 0:
        print(s)
        break


# Optimized solution
N = int(eval(input()))
S = sorted([int(eval(input())) for _ in range(N)])
s = sum(S)
if s % 10 != 0:
    print(s)
    exit()

for si in S:
    if si % 10 != 0:
        print((s - si))
        exit()

print((0))
# Original solution
# C - Bugged
def main():
    n = int(eval(input()))
    s = [int(eval(input())) for _ in range(n)]
    s.sort()
  
    if sum(s) % 10 != 0:
        print((sum(s)))
    else:
        for i in range(n):
            if s[i] % 10 != 0:
                s.pop(i)
                print((sum(s)))
                exit()
        else:
            print((0))


if __name__ ==  "__main__":
    main()

# Optimized solution
# C - Bugged
def main():
    n = int(eval(input()))
    s = [int(eval(input())) for _ in range(n)]
    s.sort()
  
    if sum(s) % 10 != 0:
        print((sum(s)))
    else:
        for i in range(n):
            if s[i] % 10 != 0:
                print((sum(s)-s[i]))
                exit()
        else:
            print((0))


if __name__ ==  "__main__":
    main()
# Original solution
N = int(eval(input()))
src = [int(eval(input())) for i in range(N)]
if all(a%10==0 for a in src):
    print((0))
    exit()
sm = sum(src)
if sm%10==0:
    for a in sorted(src):
        if a%10==0: continue
        print((sm-a))
        exit()
else:
    print(sm)


# Optimized solution
N = int(eval(input()))
src = [int(eval(input())) for i in range(N)]
sm = sum(src)
if sm%10:
    print(sm)
    exit()
for a in sorted(src):
    if a%10:
        print((sm - a))
        exit()
else:
    print((0))
# Original solution
import itertools
n = int(eval(input()))
s = list(map(int, [eval(input()) for _ in range(n)]))
ans = []
for i in range(1, n + 1):
  for j in itertools.combinations(s, i):
    sum_ = sum(j)
    if sum_ % 10 == 0:
      sum_ = 0
    ans.append(sum_)
print((max(ans)))

# Optimized solution
n = int(eval(input()))
s = list(map(int, [eval(input()) for _ in range(n)]))
if sum(s) % 10 == 0:
  while sum(s) % 10 == 0 and len(s) > 0:
    s = sorted(s)
    i = 0
    while s[i] % 10 == 0 and i + 1 < len(s):
      i += 1
    del s[i]
  print((sum(s)))
else:
  print((sum(s)))