CodeEff/ECCO huggingface dataset:
# Original solution
# -*- coding: utf-8 -*-
import sys

N=eval(input())
S=["None"]+list(input())
Q=eval(input())
query=[ sys.stdin.readline().split() for _ in range(Q) ]

#BIT
bit=[ [ 0 for _ in range(N+1) ] for _ in range(27) ]  #中も外も1-indexed bit[1]:aのbit, bit[2]:bのbit ...

def add(idx,a,w):
    while a<=N:
        bit[idx][a]+=w
        a+=a&-a

def sum(idx,a):
    ret=0
    while 0<a:
        ret+=bit[idx][a]
        a-=a&-a
    return ret

for i,x in enumerate(S):
    if i==0: continue
    add(ord(x)-96,i,1)  #a~zのどのbit配列か,特定文字のbit配列の何番目,bitに代入する値


for q1,q2,q3 in query:
    q1=int(q1)
    q2=int(q2)
    if q1==1:
        before_q3=S[q2] #文字列Sの変更前の文字をbefore_q3に代入
        S[q2]=q3        #文字列Sの変更部分1文字を更新
        q3=ord(q3)-96                   #変更後の文字をアスキーコード10進数で表現
        before_q3=ord(before_q3)-96     #変更前の文字をアスキーコード10進数で表現
        add(q3,q2,1)                    #a~zのどのbit配列か,特定文字のbit配列の何番目,bitに代入する値
        add(before_q3,q2,-1)    #置き代えた文字は-1しなきゃいけない
    elif q1==2:
        q3=int(q3)
        cnt=0
        for i in range(1,27):
            if 0<sum(i,q3)-sum(i,q2-1):
                cnt+=1
        print(cnt)

# Optimized solution
# -*- coding: utf-8 -*-
import sys

N=eval(input())
S=["None"]+list(input())
Q=eval(input())
query=[ sys.stdin.readline().split() for _ in range(Q) ]

#BIT
bit=[ [ 0 for _ in range(N+1) ] for _ in range(27) ]  #1-indexed bit[1]:aのbit, bit[2]:bのbit ...

def add(idx,a,w):
    while a<=N:
        bit[idx][a]+=w
        a+=a&-a

def sum(idx,a):
    ret=0
    while 0<a:
        ret+=bit[idx][a]
        a-=a&-a
    return ret

for i,x in enumerate(S):
    if i==0: continue
    add(ord(x)-96,i,1)  #a~zのどのbit配列か,特定文字のbit配列の何番目,bitに代入する値


for q1,q2,q3 in query:
    q1=int(q1)
    q2=int(q2)
    if q1==1:
        before_q3=S[q2] #文字列Sの変更前の文字をbefore_q3に代入
        S[q2]=q3        #文字列Sの変更部分1文字を更新
        q3=ord(q3)-96                   #変更後の文字をアスキーコード10進数で表現
        before_q3=ord(before_q3)-96     #変更前の文字をアスキーコード10進数で表現
        add(q3,q2,1)                    #a~zのどのbit配列か,特定文字のbit配列の何番目,bitに代入する値
        add(before_q3,q2,-1)    #置き代えた文字は-1しなきゃいけない
    elif q1==2:
        q3=int(q3)
        cnt=0
        for i in range(1,27):
            if 0<sum(i,q3)-sum(i,q2-1):
                cnt+=1
        print(cnt)
# Original solution
from collections import Counter

def main():
    n = int(input().strip())
    s = list(input().strip())

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

    def query(i):
        result = Counter()
        while i:
            result += bit[i]
            i -= i & -i
        return result
    
    def update(i, cnt):
        while i < len(bit):
            bit[i] += cnt
            i += i & -i

    for i, c in enumerate(s, 1):
        update(i, Counter({c: 1}))

    q = int(input().strip())
    for _ in range(q):
        Q = input().strip().split()
        if Q[0] == "1":
            i, c = int(Q[1]), Q[2]
            if s[i - 1] != c:
                update(i, Counter({s[i - 1]: -1, c: 1}))
                s[i - 1] = c
        else:
            cnt = query(int(Q[2])) - query(int(Q[1]) - 1)
            print((len(cnt)))


main()


# Optimized solution
def main():
    n = int(input().strip())
    s = list(input().strip())

    bit = [[0] * 26 for _ in range(n + 1)]

    def query(i):
        result = [0] * 26
        while i:
            for j, x in enumerate(bit[i]):
                result[j] += x
            i -= i & -i
        return result
    
    def update(i, c, val):
        j = ord(c) - ord("a")
        while i < len(bit):
            bit[i][j] += val
            i += i & -i

    for i, c in enumerate(s, 1):
        update(i, c, 1)

    q = int(input().strip())
    for _ in range(q):
        Q = input().strip().split()
        if Q[0] == "1":
            i, c = int(Q[1]), Q[2]
            update(i, s[i - 1], -1)
            update(i, c, 1)
            s[i - 1] = c
        else:
            l, r = int(Q[1]), int(Q[2])
            cnt = [x - y for x, y in zip(query(r), query(l - 1))]
            print((sum(x > 0 for x in cnt)))


main()
# Original solution
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    R = 2**(N.bit_length())
    st = [0] * (R*2)

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += R-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(a,b,n,l,r):
        ret = 0
        if a <= l and r <= b: return st[n]
        if a < r and b > l:
            vl = query(a,b,n*2+1,l,(l+r)//2)
            vr = query(a,b,n*2+2,(l+r)//2,r)
            ret = vl | vr
        return ret

    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1,0,0,R)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt)


if __name__ == '__main__':
    main()

# Optimized solution
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    R = 2**(N.bit_length())
    st = [0] * (R*2)

    def update(i,s):
        x = 2 ** (ord(s) - ord('a'))
        i += R-1
        st[i] = x
        while i > 0:
            i = (i-1) // 2
            st[i] = st[i*2+1] | st[i*2+2]

    def query(l,r):
        l += R-1
        r += R-2
        ret = 0

        while l+1 < r:
            if l % 2 == 0:
                ret |= st[l]
            if r % 2 == 1:
                ret |= st[r]
                r -= 1
            l = l // 2
            r = (r-1) // 2
        if l == r:
            ret |= st[l]
        else:
            ret |= st[l] | st[r]

        return ret

    for i,s in enumerate(sys.stdin.readline().rstrip()):
        update(i+1,s)
    Q = NI()
    for _ in range(Q):
        c,a,b = sys.stdin.readline().split()
        if c == '1':
            update(int(a),b)
        else:
            ret = query(int(a),int(b)+1)
            cnt = 0
            b = 1
            for i in range(26):
                cnt += (b & ret) > 0
                b <<= 1
            print(cnt)


if __name__ == '__main__':
    main()
# Original solution
import sys
input = sys.stdin.readline

n = int(input().rstrip('\n'))
s = input().rstrip('\n')
l = [c for c in s]
q = int(input().rstrip('\n'))
Q = [input().rstrip('\n').split() for _ in range(q)]

class SegTree():
    def __init__(self, n_):
        self.n = 1
        while self.n < n_:
            self.n *= 2
        self.tree = [2 for _ in range(2 * self.n - 1)]
    def update(self, k, a):
        k += self.n - 1
        self.tree[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.tree[k] = min(self.tree[k * 2 + 1], self.tree[k * 2 + 2])
    def query(self, l, r):
        l += self.n - 1
        r += self.n - 2
        res = 2
        while r-l>1:
            if l&1 == 0:
                res = min(res,self.tree[l])
            if r&1 == 1:
                res = min(res,self.tree[r])
                r -= 1
            l = l//2
            r = (r-1)//2
        if l == r:
            res = min(res,self.tree[l])
        else:
            res = min(min(res,self.tree[l]),self.tree[r])
        return res

d = { c: SegTree(n) for c in "abcdefghijklmnopqrstuvwxyz"}

for i, c in enumerate(s):
    d[c].update(i, 1)


for a, b, c in Q:
    if a == "1":
        b = int(b) - 1
        d[l[b]].update(b, 2)
        d[c].update(b, 1)
        l[b] = c
    else:
        res = 0
        b, c = int(b), int(c)
        for key in d:
            if d[key].query(b-1, c) == 1:
                res += 1
        print(res)


# Optimized solution
import sys
input = sys.stdin.readline

n = int(input().rstrip('\n'))
s = input().rstrip('\n')
q = int(input().rstrip('\n'))
Q = []

for _ in range(q):
    Q.append(input().rstrip().split())

class SegTree():
    def __init__(self, n_):
        self.n = 1
        while self.n < n_:
            self.n *= 2
        self.tree = []
        for _ in range(2 * self.n - 1):
            self.tree.append(2)
    def update(self, k, a):
        k += self.n - 1
        self.tree[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.tree[k] = min(self.tree[k * 2 + 1], self.tree[k * 2 + 2])
    def query(self, l, r):
        l += self.n - 1
        r += self.n - 2
        res = 2
        while r-l>1:
            if l&1 == 0:
                res = min(res,self.tree[l])
            if r&1 == 1:
                res = min(res,self.tree[r])
                r -= 1
            l = l//2
            r = (r-1)//2
        if l == r:
            res = min(res,self.tree[l])
        else:
            res = min(min(res,self.tree[l]),self.tree[r])
        return res

d = { c: SegTree(n) for c in "abcdefghijklmnopqrstuvwxyz"}
l = []

for i, c in enumerate(s):
    d[c].update(i, 1)
    l.append(c)

for a, b, c in Q:
    if a == "1":
        b = int(b) - 1
        d[l[b]].update(b, 2)
        d[c].update(b, 1)
        l[b] = c
    else:
        res = 0
        b, c = int(b), int(c)
        for key in d:
            if d[key].query(b-1, c) == 1:
                res += 1
        print(res)
# Original solution
import sys
input=sys.stdin.buffer.readline
n=int(eval(input()))+1
data=[0]*n*2
def update(i,x):
  i+=n
  data[i]=x
  i//=2
  while i:
    data[i]=data[i*2]|data[i*2+1]
    i//=2
def query(l,r):
  l+=n
  r+=n
  s=0
  while l<r:
    if l&1:
      s|=data[l]
      l+=1
    if r&1:
      r-=1
      s|=data[r]
    l//=2
    r//=2
  return sum(map(int,bin(s)[2:]))
for i,c in enumerate(input()[:-1],n):data[i]=2**(c-97)
for i in range(n-1,0,-1):data[i]=data[i*2]|data[i-~i]
for _ in range(int(eval(input()))):
  q,a,b=input().split()
  if q[0]>49:print((query(int(a)-1,int(b))))
  else:update(int(a)-1,2**(b[0]-97))

# Optimized solution
def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(eval(input()))+1
  data=[0]*n*2
  def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
      data[i]=data[i*2]|data[i*2+1]
      i//=2
  def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
      if l&1:
        s|=data[l]
        l+=1
      if r&1:
        r-=1
        s|=data[r]
      l//=2
      r//=2
    return bin(s).count('1')
  for i,c in enumerate(input()[:-1],n):data[i]=2**(c-97)
  for i in range(n-1,0,-1):data[i]=data[i*2]|data[i-~i]
  s=[]
  for _ in range(int(eval(input()))):
    q,a,b=input().split()
    if q[0]>49:s+=query(int(a)-1,int(b)),
    else:update(int(a)-1,2**(b[0]-97))
  print(('\n'.join(map(str,s))))
main()
# Original solution
n,s,_,*t=open(0).read().split()
n=int(n)
d=[0]*n+[1<<ord(c)-97for c in s]
for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
for q,a,b in zip(*[iter(t)]*3):
  i,s=int(a)+n-1,0
  if'2'>q:
    d[i]=1<<ord(b)-97
    while i>1:
      i//=2
      d[i]=d[i+i]|d[i-~i]
    continue
  j=int(b)+n
  while i<j:
    if i&1:
      s|=d[i]
      i+=1
    if j&1:
      j-=1
      s|=d[j]
    i//=2
    j//=2
  print((bin(s).count('1')))

# Optimized solution
def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<ord(b)-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print((bin(s).count('1')))
main()
# Original solution
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w):
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def sum(self,x):
        x += 1
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
bits = [BinaryIndexedTree(N) for _ in range(26)]

for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)

s = list(S)
ans = []
for a,b,c in qs:
    if a=='1':
        x = int(b)-1
        bits[ctoi(c)].add(x,1)
        bits[ctoi(s[x])].add(x,-1)
        s[x] = c
    else:
        b,c = int(b)-1,int(c)-1
        tmp = 0
        for i in range(26):
            if bits[i].sum(c) - bits[i].sum(b-1) > 0:
                tmp += 1
        ans.append(tmp)
print(*ans, sep='\n')


# Optimized solution
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w):
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x):
        x += 1
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r):
        return self._sum(r-1) - self._sum(l-1)
bits = [BinaryIndexedTree(N) for _ in range(26)]

for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)

s = list(S)
ans = []
for a,b,c in qs:
    if a=='1':
        x = int(b)-1
        bits[ctoi(c)].add(x,1)
        bits[ctoi(s[x])].add(x,-1)
        s[x] = c
    else:
        b,c = int(b)-1,int(c)
        tmp = 0
        for i in range(26):
            if bits[i].sum(b,c) > 0:
                tmp += 1
        ans.append(tmp)
print(*ans, sep='\n')
# Original solution
import sys
input = sys.stdin.readline
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        if i == 0:
            return 0
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
aas = "abcdefghijklmnopqrstuvwxyz"
N = int(input().strip())
S = list(input().strip())
Q = int(input().strip())
cbt = dict()
MX = 5 * 10**5 + 2
for c in aas:
    cbt[c] = Bit(MX)
    for i, a in enumerate(S):
        if a == c:
            cbt[c].add(i+1, 1)

for _ in range(Q):
    t, i, c = input().split()
    t = int(t)
    if t == 1:
        i = int(i)
        if S[i-1] != c:
            cbt[S[i-1]].add(i, -1)
            cbt[c].add(i, 1)
            S[i-1] = c
    else:
#        print(S)
        l, r = int(i), int(c)
#        print(l, r)
        s = 0
        for a in aas:
            bt = cbt[a]
#            print(a, bt.sum(r),bt.sum(l-1))
            s += (bt.sum(r)-bt.sum(l-1)>0)
        print(s)


# Optimized solution
import sys
input = sys.stdin.readline
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        if i == 0:
            return 0
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
aas = "abcdefghijklmnopqrstuvwxyz"
N = int(input().strip())
S = [" "]+list(input().strip())
Q = int(input().strip())
cbt = dict()
for c in aas:
    cbt[c] = Bit(N)
    for i, a in enumerate(S):
        if i == 0:
            continue
        if a == c:
            cbt[c].add(i, 1)

for _ in range(Q):
    t, i, c = input().split()
    t = int(t)
    if t == 1:
        i = int(i)
        if S[i] != c:
            cbt[S[i]].add(i, -1)
            cbt[c].add(i, 1)
            S[i] = c
    else:
        l, r = int(i), int(c)
        s = 0
        for a in aas:
            bt = cbt[a]
            s += (bt.sum(r)-bt.sum(l-1)>0)
        print(s)
# Original solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)


def main():
    N = int(readline())
    S = readline().strip()
    Q = int(readline())
    query = [readline().split() for _ in range(Q)]

    bit = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        bit[ord(c) - ord('a')].add(i)

    S = list(S)
    ans = []

    for q in query:
        if q[0] == '1':
            i = int(q[1]) - 1
            c = q[2]
            bit[ord(S[i]) - ord('a')].add(i, -1)
            bit[ord(c) - ord('a')].add(i, 1)
            S[i] = c
        else:
            res = 0
            l, r = int(q[1]) - 1, int(q[2]) - 1
            for i in range(26):
                if bit[i].get_sum_range(l, r + 1):
                    res += 1
            ans.append(res)

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def add(self, i, x=1):
        i += 1
        while i <= self.n:
            self.data[i] += x
            i += i & -i

    def get_sum(self, i):
        i += 1
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i & -i
        return x

    # Return sum for [l, r)
    def get_sum_range(self, l, r):
        return self.get_sum(r - 1) - self.get_sum(l - 1)


def main():
    N = int(readline())
    S = readline().strip()
    Q = int(readline())

    bit = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        bit[ord(c) - ord('a')].add(i)

    S = list(S)
    ans = []

    for _ in range(Q):
        n, a, b = readline().split()
        if n == '1':
            i = int(a) - 1
            if b != S[i]:
                bit[ord(S[i]) - ord('a')].add(i, -1)
                bit[ord(b) - ord('a')].add(i, 1)
                S[i] = b
        else:
            res = 0
            l, r = int(a) - 1, int(b) - 1
            for i in range(26):
                if bit[i].get_sum_range(l, r + 1):
                    res += 1
            ans.append(res)

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()
# Original solution
class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


if __name__ == "__main__":
    N = int(input())
    S = list(input())
    d = {x: i for i, x in enumerate("abcdefghijklmnopqrstuvwxyz")}
    BIT = [BinaryIndexTree(N) for _ in range(26)]

    # initialize
    for i, s in enumerate(S, start=1):
        BIT[d[s]].add(i, 1)

    Q = int(input())
    ans = []
    for _ in range(Q):
        query, x, y = input().split()
        if query == "1":
            i = int(x)
            c_new = y
            c_old = S[i - 1]
            BIT[d[c_new]].add(i, 1)
            BIT[d[c_old]].add(i, -1)
            S[i - 1] = c_new
        else:
            cnt = 0
            l = int(x) - 1
            r = int(y)
            for b in BIT:
                tmp = b.sum(r) - b.sum(l)
                if tmp:
                    cnt += 1
            ans.append(cnt)

    print(*ans, sep="\n")


# Optimized solution
class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def Alp(s):
    return ord(s)-ord("a")


if __name__ == "__main__":
    N = int(input())
    S = list(input())
    Q = int(input())

    bit = [BinaryIndexTree(N) for _ in range(26)]
    for i, s in enumerate(S, start=1):
        bit[Alp(s)].add(i, 1)

    ans = []
    for _ in range(Q):
        q = input().split()
        if q[0] == "1":
            i = int(q[1]) - 1
            c = q[2]

            bit[Alp(c)].add(i+1, 1)
            bit[Alp(S[i])].add(i+1, -1)
            S[i] = c
        else:
            l = int(q[1])
            r = int(q[2])
            tmp = 0
            for i in range(26):
                b = bit[i]
                if b.sum(r) - b.sum(l - 1) > 0:
                    tmp += 1
            ans.append(tmp)

    print(*ans, sep="\n")
# Original solution
import sys
N = int(eval(input()))
scores = [0]*(N*100+1)
scores[0] = 1

for _ in range(N):
    a = int(eval(input()))
    for i in reversed(list(range(len(scores)))):
        if scores[i]>0 and 0<i+a<=N*100:
            scores[i+a] += 1
            
for i in reversed(list(range(len(scores)))):
    if scores[i] and i % 10 != 0:
        print(i)
        sys.exit()
            
print((0))

# Optimized solution
N = int(eval(input()))
a = list(int(eval(input())) for _ in range(N))
a.sort()

ans = sum(a)
if ans%10 > 0:
    print(ans)
    exit()
for ai in a:
    if ai%10 > 0:
        print((ans - ai))
        break
else:
    print((0))
# Original solution
N = int(eval(input()))

s = []
sum = 0
min_nonten = 999
all_ten = True
for i in range(N):
    s.append(int(eval(input())))
    sum += s[i]
    if(s[i] % 10 != 0):
        all_ten = False
        if(min_nonten > s[i]):
            min_nonten = s[i]


if(sum % 10 != 0):
    print(sum)
elif(all_ten):
    print((0))
else:
    print((sum - min_nonten))

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

# Optimized solution
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)
# Original solution
import itertools as it
n = int(eval(input()))
s = [int(eval(input())) for _ in range(n)]

ans = [0]
for i in range(1,n+1) :
    sa = list(it.combinations(s,i))
    for j in range(len(sa)) :
        if sum(sa[j])%10 != 0 :
            ans.append(sum(sa[j]))

print((max(ans)))

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


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

while len(s)>0 :
    m = min(s)
    sum -= m
    if sum%10 != 0 :
        print(sum)
        exit()

print((0))