CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
a = [int(eval(input())) for _ in range(N)]
def sol(i, cur):
    if i == -1:
        return cur
    else:
        tmp1 = sol(i-1, cur+a[i])
        tmp1 = tmp1 if tmp1 % 10  else 0
        tmp2 = sol(i-1, cur)
        tmp2 = tmp2 if tmp2 % 10 else 0
        return max(tmp1, tmp2)
print((sol(N-1, 0)))

# Optimized solution
N = int(eval(input()))
a = [int(eval(input())) for _ in range(N)]
ans = sum(a)
if ans % 10 == 0:
    if all([i % 10 == 0 for i in a]):
        print((0))
    else:
        ans -= min([i for i in a if i % 10 != 0])
        print(ans)
else:
    print(ans)
# Original solution
from itertools import chain, combinations
def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

N = int(eval(input()))
s = [int(eval(input())) for i in range(N)]
list1 = list([x for x in map(sum,powerset(s)) if x % 10])
list1.append(0)
print((max(list1)))

# Optimized solution
N = int(eval(input()))
s = [int(eval(input())) for i in range(N)]
sums = sum(s)
others = list([x for x in s if x % 10])
if sums % 10:
    print(sums)
elif others != []:
    print((sums-min(others)))
else:
    print((0))
# Original solution
def main():
    n = int(eval(input()))
    s = [int(eval(input())) for _ in range(n)]
    s_sum = []
    def dfs(i, sum):
        if i == n:
            s_sum.append(sum)
        else:
            dfs(i + 1, sum + s[i])
            dfs(i + 1, sum)
    dfs(0, 0)
    s_sum_c = [s for s in s_sum if s % 10 != 0]
    s_sum_c.append(0)
    print((max(s_sum_c)))

if __name__ == '__main__':
    main()

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

if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
dat_s = []
for i in range(n):
    dat_s.append(int(eval(input())))
total = sum(dat_s)
f = True

if total % 10 != 0:
    print(total)
    f = False
else:
    dat_s.sort()
    for i in range(len(dat_s)):
        if dat_s[i] % 10 != 0:
            print((total - dat_s[i]))
            f = False
            break

if f:
    print("0")

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

# 0個選択したときのスコア(重複は意味がないのでset)
scores = set([0])

# 1～n問まで回す
for i in range(n):
    # ここまでで可能性のあるスコアをbufferにいれて
    b = set(scores)
    while len(b) != 0:
        # いまのn問目のスコアをこのスコアに足していく
        scores.add(dat_s[i] + b.pop())

# 可能性のあるスコアの中から10で割り切れるスコアは消す(=0にする)
scores = [0 if x % 10 == 0 else x for x in scores]
print((max(scores)))
# Original solution
import itertools
import sys

N=int(eval(input()))
S=[int(eval(input())) for _ in range(N)]
ans=0

if sum(S)%10!=0:
  print((sum(S)))
  sys.exit()

i=N-1
while True:
  if ans!=0 or i==0:
    break
  for j in itertools.combinations(S,i):
    s=sum(j)
    if s%10!=0:
      ans=max(ans,s)
  i-=1

print(ans)

# Optimized solution
import sys

N=int(eval(input()))
S=[int(eval(input())) for _ in range(N)]
S.sort()
ans=sum(S)

if ans%10!=0:
  print(ans)
  sys.exit()
else:
  for i in range(N):
    if S[i]%10!=0:
      print((ans-S[i]))
      sys.exit()
  else:
    print((0))
# Original solution
N=int(eval(input()))
item = [int(eval(input())) for i in range(N)]
ans=0
for i in range(2 ** N):
    out = 0
    for j in range(N):  # このループが一番のポイント
        if (i >> j) & 1:  # 順に右にシフトさせ最下位bitのチェックを行う
            out+=item[j]  # フラグが立っていたら 加算する
    if str(out)[-1]=='0':
        out = 0
    ans=max(ans,out)
print(ans)

# Optimized solution
N=int(eval(input()))
items = [int(eval(input())) for i in range(N)]
tot=sum(items)
ans=0
if tot%10!=0:
  ans=tot
else:
  items.sort()
  for i in range(N):
    if items[i]%10!=0:
      ans=tot-items[i]
      break
print(ans)
# Original solution
_,*l=list(map(int,open(0).read().split()));s=sum(l)
print((0 if all(i%10<1 for i in l) else s-min(i for i in l if i%10)*(s%10<1)))

# Optimized solution
_,*l=list(map(int,open(0)));s=sum(l)
print((0 if all(i%10<1 for i in l) else s-min(i for i in l if i%10)*(s%10<1)))
# Original solution
n=int(eval(input()))
li=[]
for i in range(n):
  li.append(int(eval(input())))
pl=[0]
for i in range(2**n):
  point=0
  for j in range(n):
    if ((i>>j)&1):
      point+=li[j]
  if point%10!=0:
    pl.append(point)
pl.sort(reverse=True)
for i in pl:
  if i%10!=0:
    print(i)
    break
else:
  print((0))
    

# Optimized solution
n=int(eval(input()))
li=[]
for i in range(n):
  li.append(int(eval(input())))
out=sum(li)
if out%10!=0:
  print(out)
else:
  li.sort()
  for i in li:
    if i%10!=0:
      print((out-i))
      break
  else:
    print((0))
# Original solution
n = int(eval(input()))
s = [int(eval(input())) for _ in range(n)]

sum = [0]
for i in range(n):
    temp = []
    for x in sum:
        temp.append(x)
        temp.append(x+s[i])
        sum = temp[::]

dp = [i for i in sum if i % 10 != 0]
print((max(dp) if dp != [] else '0'))

# Optimized solution
n = int(eval(input()))
s = sorted([int(eval(input())) for _ in range(n)])
if sum(s) % 10 != 0:
    print((sum(s)))
    quit()
else:
    for i in s:
        if i % 10 != 0:
            s.remove(i)
            print((sum(s)))
            quit()
print('0')
# Original solution
N = int(eval(input()))
s = [int(eval(input())) for _ in range(N)]
ans = 0
for i in range(2**N):
    correct = []
    su = 0
    for j in range(N):
        if ((i >> j) & 1):
            su += s[j]
    if su % 10 == 0:
      su = 0
    ans = max(ans,su)
print(ans)
            


# Optimized solution
N = int(eval(input()))
s = [int(eval(input())) for _ in range(N)]
s.sort()
ans = sum(s)

if ans % 10 != 0:
  print(ans)
else:
  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)]

# bit全探索
s_max = 0
for bit in range(1<<n):

    s_tmp = 0
    for i in range(n):
        if bit >> i & 1:
            s_tmp += s[i]
    
    if s_tmp % 10 == 0:
        s_tmp = 0

    s_max = max(s_max, s_tmp)
    
print(s_max)

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

s.sort()
s_max = sum(s)

if s_max % 10 != 0:
    print(s_max)
    exit()
else:
    for i in s:
        if i % 10 != 0:
            print((s_max - i))
            exit()

print((0))
# Original solution
N = int(eval(input()))

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

ans = 0
# bit 全探索する
for bit in range(1 << N):
    sum = 0

    for i in range(N):
        # bit にi 番目のフラグが立っているかどうか
        if bit & (1 << i):
            # フラグが立っているならsumに加算する
            sum += S[i]

    if sum % 10 == 0:
        sum = 0
    ans = max(ans, sum)

print(ans)

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

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

ans = sum(S)
if ans % 10 == 0: # 10の倍数の時
    min_s = float('inf')
    for s in S: # sの中から, 10の倍数でない、かつ最小のものを探してくる
        if s % 10 != 0:
            min_s = min(min_s, s)
    if min_s == float('inf'): # sの中に10の倍数でないものがなかったとき
        ans = 0
    else:
        ans -= min_s

print(ans)
# Original solution
import sys

n, *s = list(map(int, sys.stdin.read().split()))

def main():
    res = sum(s)
    if res % 10:
        return res
    else:
        not_multiple_of_10 = [x for x in s if x % 10]
        if not_multiple_of_10:
            return res - min(not_multiple_of_10)
        else:
            return 0

if __name__ == '__main__':
    ans = main()
    print(ans)

# Optimized solution
import sys

n, *a = list(map(int, sys.stdin.read().split()))

def main():
  s = sum(a)
  if s % 10: ans = s
  else: 
    m = min([101] + [x for x in a if x % 10])
    if m == 101: ans = 0
    else: ans = s - m
  print(ans)

if __name__ == '__main__':
  main()
# Original solution
N = int(eval(input()))

s = []
for _ in range(N):
    s += [int(eval(input()))]

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

print (ans)

# Optimized solution
#Nの最大値が100なのでbit-DPでは間に合わない

N = int(eval(input()))

s = []
total = 0
for _ in range(N):
    a = int(eval(input()))
    s += [a]
    total += a

s.sort()
if total % 10 != 0:
    print (total)
    exit()
else:
    for i in range(N):
        if s[i]%10 != 0:
            print((total - s[i]))
            exit()
print((0))
# Original solution
# ABC063c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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


def dfs(i, su):
    if i == n:
        return su if su % 10 != 0 else 0
    return max(dfs(i+1, su+s[i]), dfs(i+1, su))


print((dfs(0, 0)))


# Optimized solution
# ABC063c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

s.sort()
ans = sum(s)
if ans % 10 != 0:
    print(ans)
    exit(0)
for i in s:
    if i % 10 != 0:
        ans -= i
        print(ans)
        exit(0)
print((0))
# Original solution
n = int(eval(input()))
ten = []
notten = []
for _ in range(n):
  s = int(eval(input()))
  if s % 10:
    notten.append(s)
  else:
    ten.append(s)
ans = sum(notten) + sum(ten)
if notten and sum(notten) % 10 == 0:
  print((ans - min(notten)))
elif ans % 10 == 0:
  print((0))
else:
  print(ans)
  

# Optimized solution
n = int(eval(input()))
s = []
for _ in range(n):
    i = int(eval(input()))
    s.append(i)
s.sort()
ans = sum(s)
if ans % 10 == 0:
    for i in s:
        if i % 10 != 0:
            ans -= i
            print(ans)
            break
    else:
        print((0))
else:
    print(ans)
# Original solution
def myAnswer(N:int,S:list) -> int:
   ans = []
   for s in S:
      if(s % 10 != 0):
         ans.append(s)
   ans.sort()
   ans = list(set(ans))
   total = sum(S)
   if(total % 10 == 0):
      if(ans != []):
         return total - ans[0]
      else:
         return 0
   else:
      return total

def modelAnswer():
   return
def main():
   N = int(eval(input()))
   S = [int(eval(input())) for _ in range(N)]
   print((myAnswer(N,S[:])))
if __name__ == '__main__':
   main()

# Optimized solution
def myAnswer(N:int,S:list) -> int:
   MIN = 0
   total = sum(S)
   S.sort()

   for s in S:
      if(s % 10 != 0):
         MIN = s
         break
   if(total % 10 == 0):
      if(MIN != 0):
         return total - MIN
      else:
         return 0
   else:
      return total

def modelAnswer():
   return
def main():
   N = int(eval(input()))
   S = [int(eval(input())) for _ in range(N)]
   print((myAnswer(N,S[:])))
if __name__ == '__main__':
   main()
# Original solution
import itertools
N = int(eval(input()))
s = [0] * N
answer = 0
for i in range(N):
    s[i] = int(eval(input()))
for i in range(1, N+1):  # 何問正解するか、0からN問まで
    for v in itertools.combinations(s, i):
        if sum(v) % 10 != 0 and answer <= sum(v):
            answer = sum(v)
        # print(v, sum(v))

print(answer)
        

# Optimized solution
import itertools
N = int(eval(input()))
s = [0] * N
not10 = []
answer = 0
for i in range(N):
    s[i] = int(eval(input()))

SUM = sum(s)
if SUM % 10 != 0:
    print(SUM)
    exit()
else:
    for i in range(N):
        if s[i] % 10 != 0:
            not10.append(s[i])
    not10.sort()
    if len(not10) == 0:
        print((0))
    else:
        print((SUM - not10[0]))
    exit()
            
# print(not10)

# for i in range(1, N+1):  # 何問正解するか、0からN問まで
#     for v in itertools.combinations(s, i):
#         if sum(v) % 10 != 0 and answer <= sum(v):
#             answer = sum(v)
#         print(v, sum(v))

# print(answer)
# Original solution
import itertools

N=int(eval(input()))
A=[0]*N
for i in range(N):
    A[i]=int(eval(input()))

m=0
for i in range(N):
    n=N-i
    L=list(itertools.combinations(A,n))
    L=sorted(L)
    for j in range(len(L)):
        #print(L[-1-j])
        c=sum(L[-1-j])
        if(c%10!=0):
            m=max(c,m)
            break

print(m)

# Optimized solution
import itertools

N=int(eval(input()))
A=[0]*N
for i in range(N):
    A[i]=int(eval(input()))

m=sum(A)

if(m%10==0):
    A=sorted(A)
    for a in A:
        if a%10!=0:
            print((m-a))
            exit()
    print((0))
else:
    print(m)
# Original solution
n=int(eval(input()))
s=[]
for i in range(n):
    s.append(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=[]
for i in range(n):
    s.append(int(eval(input())))
s.sort()

if sum(s)%10==0:
    for i in range(n):
        if s[i]%10!=0:
            print((sum(s)-s[i]))
            exit()
    print((0))
    exit()
print((sum(s)))
# Original solution

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

    sm = sum(s)
    if sm % 10 != 0:
        print(sm)
        return

    s.sort()
    for i, ss in enumerate(s):
        if ss % 10 != 0:
            print((sm - ss))
            return
    print((0))

if __name__ == '__main__':
    main()


# Optimized solution

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

    total = sum(s)
    if total % 10 != 0:
        print(total)
        return
    s.sort()

    for i, ss in enumerate(s):
        if ss % 10 != 0:
            print((total-ss))
            return
    print((0))

if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
problem = [int(eval(input())) for _ in range(N)]

def dsf(i, sum):
    if i == N:
        if sum % 10 == 0:
            return 0
        else:
            return sum
    return max(dsf(i + 1, sum), dsf(i + 1, sum - problem[i]))

if sum(problem) % 10 != 0:
    print((sum(problem)))
else:
    print((dsf(0, sum(problem))))

# Optimized solution
N = int(eval(input()))
problem = [int(eval(input())) for _ in range(N)]
memo = [[-1] * (sum(problem) + 1)] * N
def dsf(i, sum):
    if i == N:
        if sum % 10 == 0:
            return 0
        else:
            return sum
    if memo[i][sum] != -1: return memo[i][sum]
    else:
        memo[i][sum] = max(dsf(i + 1, sum), dsf(i + 1, sum - problem[i]))
        return memo[i][sum]

if sum(problem) % 10 != 0:
    print((sum(problem)))
else:
    print((dsf(0, sum(problem))))
# Original solution
N = int(eval(input()))
s = [int(eval(input())) for _ in range(N)]
ans = 0
for i in range(1<<N):
    total = 0
    for j in range(N):
        if (i>>j)&1:
            total += s[j]
    if total%10 != 0:
        ans = max(ans,total)
print(ans)

# Optimized solution
N = int(eval(input()))
s = [int(eval(input())) for _ in range(N)]
t = [x for x in s if x%10 != 0]
total = sum(s)
if total%10 != 0:
    print(total)
else:
    if len(t) == 0:
        print((0))
    else:
        print((total-min(t)))
# Original solution
n=int(eval(input()))
s=[]
w=0
m=1000
for i in range(n):
    a=int(eval(input()))
    s.append(a)
    w+=a
    if a%10!=0:
        m=min(m,a)

if m==1000:
    print((0))
elif w%10!=0:
    print(w)
else:
    print((w-m))




# Optimized solution
n=int(eval(input()))
s=[]
l=[]
for i in range(n):
    p=int(eval(input()))
    s.append(p)
    if p%10!=0:
        l.append(p)
ans=sum(s)
if ans%10==0:
    if l==[]:
        print((0))
    else:
        print((ans-min(l)))
else:
    print(ans)
# Original solution
def score_search(sc, idx):
    if idx == len(f):
        if sc % 10 == 0:
            sc = 0
        return sc

    sc_lst = [0, 0]
    sc_lst[0] = sc + score_search(0, idx+1)
    if sc_lst[0] % 10 == 0:
        sc_lst[0] = 0
    sc += s[f[idx]]
    sc_lst[1] = sc + score_search(0, idx+1)
    if sc_lst[1] % 10 == 0:
        sc_lst[1] = 0
    return max(sc_lst)


n = int(eval(input()))
s = [int(eval(input())) for i in range(n)]
f, score = [], 0

for i in range(len(s)):
    if s[i] % 10:
        f.append(i)
    else:
        score += s[i]


best_score = score + score_search(0, 0)
if best_score % 10 == 0:
    best_score = 0

print(best_score)


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

    sum_max = sum(s)

    if sum_max % 10 == 0:
        min_p = 101
        for i in s:
            if i % 10 != 0 and i < min_p:
                min_p = i

        if min_p == 101:
            sum_max = 0
        else:
            sum_max -= min_p

    print(sum_max)


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

maxnum=0

def parm_check(n,maxnum):
    #print(tmp)
    #print(list(itertools.combinations(a,n)))
    a_sort = sorted(a,reverse=True)
    comb = list(itertools.combinations(a_sort,n))
    for j in range(len(comb)):
        sumnum = sum(comb[j])
        if(sumnum % 10 != 0 and maxnum < sumnum):
            maxnum = sumnum
            break
    return maxnum

if(__name__=="__main__"):
    N = int(eval(input()))
    a =[int(eval(input())) for i in range(N)]
    #print(sum(a))
    
    if(sum(a) % 10 != 0):
        print((sum(a)))
    else:
        for i in range(N-1,1,-1):
            maxnum = parm_check(i,maxnum)
            if(maxnum != 0):
                break

        print(maxnum)


# Optimized solution
maxnum=0

if(__name__=="__main__"):
    N = int(eval(input()))
    a =[int(eval(input())) for i in range(N)]
    #print(sum(a))
    
    if(sum(a) % 10 != 0):
        print((sum(a)))
    else:
        a_sort = sorted(a)
        for i in range(0,N):
            if(a_sort[i] % 10 != 0):
                del a_sort[i]
                maxnum = sum(a_sort)
                break
            

        print(maxnum)
# Original solution
# https://atcoder.jp/contests/abc063/tasks/arc075_a

import itertools
import collections
import bisect

def main():
    N = int(eval(input()))
    scores = []
    for _ in range(N):
        s = int(eval(input()))
        scores.append(s)

    ans = 0
    if sum(scores) % 10 != 0:
        ans = sum(scores)
    else:
        for i in range(1, len(scores)+1):
            for cand in itertools.combinations(scores, i):
                val = sum(cand)
                if val % 10 != 0:
                    ans = max(ans, val)

    print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
# https://atcoder.jp/contests/abc063/tasks/arc075_a

import itertools
import collections
import bisect

def main():
    N = int(eval(input()))
    scores = []
    for _ in range(N):
        s = int(eval(input()))
        scores.append(s)

    ans = 0
    if sum(scores) % 10 != 0:
        ans = sum(scores)
    else:
        scores.sort()
        for c in scores:
            if c % 10 != 0:
                ans = sum(scores) - c
                break

    print(ans)

if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
s = sorted([int(eval(input())) for i in range(n)])

ans = 0
if sum(s) % 10 != 0:
    print((sum(s)))
else:
    for i in s:
        if i % 10 != 0:
            ans = sum(s) - i
            print(ans)
            break
    if ans == 0:
        print(ans)


# Optimized solution
n = int(eval(input()))
s = sorted([int(eval(input())) for i in range(n)])
total = sum(s)
ans = 0
if total % 10 != 0:
    print(total)
else:
    for i in s:
        if i % 10 != 0:
            ans = total - i
            break
    print((max(0, ans)))
# Original solution
from itertools import product
 
N = int(eval(input()))
S = [int(eval(input())) for _ in range(N)]
 
mmax = 0
for pair in product(list(range(2)), repeat=N):
  sum = 0
  for i in range(len(pair)):
    sum += S[i] * pair[i]
  if sum % 10 == 0:
    continue
  mmax = max(mmax, sum)
print(mmax)

# Optimized solution
N = int(eval(input()))
S = sorted([int(eval(input())) for _ in range(N)])
 
m = 0
for s in S:
  if s % 10 != 0 and m == 0:
    m = s
    break
ans = sum(S)
if ans % 10 != 0:
  print(ans)
elif m != 0:
  print((ans-m))
else:
  print((0))
# Original solution
N = int(eval(input()))
a = [int(eval(input())) for _ in range(N)]

op_cnt = len(a)

ans = 0
for i in range(2 ** op_cnt):
    op = [0] * op_cnt  
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = a[j]
    temp = sum(op)
    if sum(op)%10 == 0:
        temp = 0
    if temp > ans:
        ans = temp

print(ans)

# Optimized solution
N = int(eval(input()))
s1 = []
s2 = []
 
for i in range(N):
    a = int(eval(input()))
    if a % 10 != 0:
        s1.append(a)
    else:
        s2.append(a)

if len(s1) == 0:
    print((0))
else:
    if sum(s1) % 10 == 0:
        print((sum(s1)-min(s1)+sum(s2)))
    else:
        print((sum(s1)+sum(s2)))
# Original solution
from itertools import combinations

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

ans = 0
for i in range(1, n + 1):
    for tpl in combinations(S, i):
        s = sum(tpl)
        if s % 10 != 0:
            ans = max(ans, s)
print(ans)

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

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    if all([i % 10 == 0 for i in s]):
        print((0))
    else:
        print((ans - min([i for i in s if i % 10 != 0])))
# Original solution
#063 C Bugged
import sys
n = int(sys.stdin.readline())
S = [int(sys.stdin.readline()) for _ in range(n)]
#print(S)

ans=[]
def saiki(total, i):
    if i==n:
        #print(total)
        ans.append(total)
    else:
        saiki(total + S[i], i+1)
        saiki(total, i+1)



saiki(0, 0)
ans.sort(reverse=True)
for a in ans:
    if a%10!=0:
        print(a)
        break
else:
    print((0))

# Optimized solution
#063 C Bugged
#動的計画法(DP)で解く
import sys
n = int(sys.stdin.readline())
S = [int(sys.stdin.readline()) for _ in range(n)]
#print(S)

dp =[[0 for _ in range(sum(S)+1)] for _ in range(n)]
dp[0][0]=1
dp[0][S[0]]=1
for i in range(1, n):
    for j in range(sum(S)+1):
        if dp[i-1][j]==1:
            dp[i][j] = 1
            dp[i][j+S[i]] = 1
    dp[i][S[i]]=1

L=[]   
for i, p in enumerate(dp[n-1]):
    if p!=0:
        L.append(i)
L.sort(reverse=True)

for l in L:
    if l%10 !=0:
        print(l)
        break
else:
    print((0))
# Original solution
def f(scores, d):
    if len(scores) == 1:
        if scores[0] % 10 == d:
            res = 0
        else:
            res = scores[0]
    else:
        f1 = scores[0] + f(scores[1:], get_fld(scores[0], d))
        if f1 % 10 == d:
            f1 = 0
        f2 = f(scores[1:], d)
        res = max(f1, f2)
    return res
 
def get_fld(score, d):
    res = d - score % 10
    if res < 0:
        res += 10
    return res     
 
N = int(eval(input()))
scores = []
for _ in range(N):
    scores.append(int(eval(input())))
print((f(scores, 0)))

# Optimized solution
def f(scores):
    res = sum(scores)
    if res % 10 == 0:
        candidates = list(score for score in scores if score % 10 != 0)
        if candidates:
            res -= min(candidates)
        else:
            res = 0
    return res
 
N = int(eval(input()))
scores = []
for _ in range(N):
    scores.append(int(eval(input())))
print((f(scores)))
# Original solution
import itertools
n = int(eval(input()))
score = [ int(eval(input())) for _ in range(n)]
cnt = max([sum(c) if sum(c) % 10 != 0 else 0 for i in sorted(range(1, n+1)) for c in itertools.combinations(score, i)])
print(cnt)


# Optimized solution
import itertools
n = int(eval(input()))
score = [ int(eval(input())) for _ in range(n)]
cnt = max([sum(c) if sum(c) % 10 != 0 else 0 for i in sorted(range(n-1, n+1)) for c in itertools.combinations(score, i)])
print(cnt)
# Original solution
N = int(eval(input()))
res = set([0])
for _ in range(N):
    s = int(eval(input()))
    res |= set([r + s for r in res])
res = list(res)
res.sort()
n = len(res)
for i in range(n-1, -1, -1):
    if res[i] % 10 == 0:
        continue
    print((res[i]))
    break
else:
    print((0))

# Optimized solution
N = int(eval(input()))
S = [int(eval(input())) for _ in range(N)]
S.sort()
total = sum(S)
T = [s for s in S if s % 10 != 0]
if total % 10 != 0:
    print(total)
elif len(T) > 0:
    print((total - T[0]))
else:
    print((0))