Harryxun/stf_run huggingface dataset:
n,k=map(int,input().split())
h=list(map(int,input().split()))
s=sorted(h,reverse=True)
cnt=0
for i in range(n):
    cnt+=s[i]
for i in range(k):
    cnt-=s[i]
print(cnt)

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
s=sorted(h,reverse=True)
cnt=0
for i in range(n):
    cnt+=s[i]
if k>=n:
  print(0)
  exit()
else:
  for i in range(k):
    cnt-=s[i]
print(cnt)
a = [[0] * 3 for x in range(3)]
s = [[0] * 3 for x in range(3)]
for i in range(3):
  a[i] = [int(x) for x in input().split()]
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))
for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i] == a[j][k]:
        s[j][k] = 1
res = "No"
if s[0][0] == 1 and s[0][1] == 1 and s[0][2] == 1:
  res = "Yes"
if s[1][0] == 1 and s[1][1] == 1 and s[1][2] == 1:
  res = "Yes"
if s[2][0] == 1 and s[2][1] == 1 and s[3][2] == 1:
  res = "Yes"
if s[0][0] == 1 and s[1][0] == 1 and s[2][0] == 1:
  res = "Yes"
if s[0][1] == 1 and s[1][1] == 1 and s[2][1] == 1:
  res = "Yes"
if s[0][2] == 1 and s[1][2] == 1 and s[2][2] == 1:
  res = "Yes"
if s[0][0] == 1 and s[1][1] == 1 and s[2][2] == 1:
  res = "Yes"
if s[2][0] == 1 and s[1][1] == 1 and s[0][2] == 1:
  res = "Yes"
print(res)

### FIXED CODE ###

a = [[0] * 3 for x in range(3)]
s = [[0] * 3 for x in range(3)]
for i in range(3):
  a[i] = [int(x) for x in input().split()]
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))
for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i] == a[j][k]:
        s[j][k] = 1
res = "No"
if s[0][0] == 1 and s[0][1] == 1 and s[0][2] == 1:
  res = "Yes"
if s[1][0] == 1 and s[1][1] == 1 and s[1][2] == 1:
  res = "Yes"
if s[2][0] == 1 and s[2][1] == 1 and s[2][2] == 1:
  res = "Yes"
if s[0][0] == 1 and s[1][0] == 1 and s[2][0] == 1:
  res = "Yes"
if s[0][1] == 1 and s[1][1] == 1 and s[2][1] == 1:
  res = "Yes"
if s[0][2] == 1 and s[1][2] == 1 and s[2][2] == 1:
  res = "Yes"
if s[0][0] == 1 and s[1][1] == 1 and s[2][2] == 1:
  res = "Yes"
if s[2][0] == 1 and s[1][1] == 1 and s[0][2] == 1:
  res = "Yes"
print(res)
if __name__ == '__main__':
    n = stdin.readline()
    n, K = n.split(' ')
    n = int(n)
    K = int(K)
    arr = stdin.readline()
    arr = [int(a) for a in arr.split(' ')]
    dp = [float('inf')]*n
    dp[0] = 0
    for i in range(n):
        for k in range(1, K+1):
            if i - k < 0:
                break
            dp[i] = min(dp[i], dp[i-k]+abs(arr[i]-arr[i-k]))
    print(dp[-1])

### FIXED CODE ###

def woo(x, y):
    res = [0]*x
    z = list(map(int, input().split()))
    for i in range(1, x):
        res[i] = min(abs(z[i] - z[j]) + res[j] for j in range(max(0, i - y), i))
    return res

if __name__ == '__main__':
    x, y = map(int, input().split())
    r = woo(x, y)
    f = len(r)-1
    print(r[f])
N = int(input())
A = list(map(int,input().split()))

l = [0]*(2**max(A))
ll = []
for a in A:
  pattern = bin(a)[2:].zfill(N)
  for i in range(len(pattern)):
    if pattern[i] == '1':
      l[i] += 1

for a in A:
  ans = ''
  pattern = bin(a)[2:].zfill(N)
  for i in range(len(pattern)):
    if pattern[i] == '1' and int(l[i])%2 == 0:
      ans += '1'
    elif pattern[i] == '0' and int(l[i])%2 != 0:
      ans += '1'
    else:
      ans += '0'
  ll.append(int(ans,2))
print(*ll)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
num = 0
for a in A:
  num ^= a

l = []

for a in A:
  ans = a^num
  l.append(ans)
print(*l)
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2


counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      try:
        counter[i]
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0

if D[0] != 0:
  ans = 0

print(ans)

### FIXED CODE ###

import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2

if D[0] != 0:
  print(0)
  exit()

counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0



print(ans)
#!/usr/bin/env python3


def main() -> None:
    H, W = rmi()
    s = []
    for h in range(H):
        line = list(map(lambda c: c == '.', list(r())))
        s.append(line)
    dp = []
    for _ in range(H):
        dp.append([-1] * W)
    dp[0][0] = 0 if s[0][0] else 1
    for h in range(1, H):
        dp[h][0] = dp[h - 1][0] if s[h][0] else dp[h - 1][0] + 1
    for w in range(1, W):
        dp[0][w] = dp[0][w - 1] if s[0][w] else dp[0][w - 1] + 1
    for h in range(1, H):
        for w in range(1, W):
            minimum = min(dp[h - 1][w], dp[h][w - 1])
            dp[h][w] = minimum if s[h][w] else minimum + 1
    print(dp[H][W])


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()


### FIXED CODE ###

#!/usr/bin/env python3


def main() -> None:
    H, W = rmi()
    s = []
    for h in range(H):
        line = list(map(lambda c: c == '.', list(r())))
        s.append(line)
    dp = []
    for _ in range(H):
        dp.append([H + W + 1] * W)
    dp[0][0] = 0 if s[0][0] else 1
    for h in range(1, H):
        dp[h][0] = dp[h - 1][0] + int(s[h - 1][0] != s[h][0] and not s[h][0])
    for w in range(1, W):
        dp[0][w] = dp[0][w - 1] + int(s[0][w - 1] != s[0][w] and not s[0][w])
    for h in range(1, H):
        for w in range(1, W):
            dp[h][w] = min(dp[h - 1][w] + int(s[h - 1][w] != s[h][w] and not s[h][w]),
                           dp[h][w - 1] + int(s[h][w - 1] != s[h][w] and not s[h][w]))
    print(dp[H - 1][W - 1])


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()
h,w,m,*t = map(int,open(0).read().split())
a = [[0]*w for _ in range(h)]
ht = [0]*h
wt = [0]*w
for i in range(m):
  y,x = t[i*2]-1,t[i*2+1]-1
  a[y][x] += 1
  ht[y] += 1
  wt[x] += 1
htm = max(ht)-1
wtm = max(wt)-1
htt = [i for i in range(h) if ht[i]>=htm]
wtt = [i for i in range(w) if wt[i]>=wtm]
ans = 0
for i in htt:
  for j in wtt:
    ans = max(ans,ht[i]+wt[j]-a[i][j])
print(ans)

### FIXED CODE ###

h,w,m = map(int,input().split())
t = [tuple(map(lambda x:int(x)-1,input().split())) for _ in range(m)] 
ht = [0]*h
wt = [0]*w
for y,x in t:
  ht[y] += 1
  wt[x] += 1
htm = max(ht)
wtm = max(wt)
htt = [i for i in range(h) if ht[i]==htm]
wtt = [i for i in range(w) if wt[i]==wtm]
ans = htm+wtm-1
t = set(t)
for i in htt:
  for j in wtt:
    if (i,j) not in t:
      print(htm+wtm)
      exit()
print(htm+wtm-1)
print( 700 + 100*input().count("o")

### FIXED CODE ###

print( 700 + 100*input().count("o"))
import sys
input = sys.stdin.readline

import heapq
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d

################################
n = int(input()) #n:頂点数　w:辺の数
w = n - 1

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    z = 1
    edge[x].append([z,y])
    edge[y].append([z,x]) 

dis_from_f = dijkstra_heap(0)
dis_from_s = dijkstra_heap(n - 1)

cnt = 0
for i, j in zip(dis_from_f, dis_from_s):
    if i <= j:
        cnt += 1
if cnt > n - cnt:
    print("Fennec")
else:
    print("Snuke")

### FIXED CODE ###

import sys
input = sys.stdin.readline

#O(ElogV)
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

################################
n = int(input()) #n:頂点数　w:辺の数
w = n - 1

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    z = 1
    edge[x].append([z,y])
    edge[y].append([z,x]) 

dis_from_f = dijkstra_heap(0)
dis_from_s = dijkstra_heap(n - 1)

cnt = 0
for i, j in zip(dis_from_f, dis_from_s):
    if i <= j:
        cnt += 1
if cnt > n - cnt:
    print("Fennec")
else:
    print("Snuke")
S = input()
N = len(S)
ans = 0
for i in range(N):
for j in range(i, N):
if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
ans = max(ans, j - i + 1)
print(ans)


### FIXED CODE ###

S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)
A = map(int, input().split())
if A.sort() == [5,5,7]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

A = list(map(int, input().split()))
A.sort()
if A == [5,5,7]:
  print("YES")
else:
  print("NO")
K,X=map(int,input().split())

if 500＊K　>=　X:
  print('yes')
else:
  print('no')

### FIXED CODE ###

K,X=map(int,input().split())

if 500*K >= X:
  print('Yes')
else:
  print('No')
H, W, A, B = (int(i) for i in input().split())

#H, W, A, B = (10, 7, 3, 4)
#H, W, A, B = (2, 3, 1, 1)

def mycomb(n, k):
    return factorials[n] / (factorials[k] * factorials[n - k])

MOD = int(1e9 + 7)

factorials = []
factorials.append(1)
for i in range(1, W + H):
    factorials.append(factorials[i - 1] * i)

r = 0
for i in range(H - A):
    combination = mycomb(B-1+i, B-1) * mycomb(W+H-B-i-2, W-B-1)
    r += combination % MOD

print(r)

### FIXED CODE ###

H, W, A, B = (int(i) for i in input().split())

#H, W, A, B = (10, 7, 3, 4)
#H, W, A, B = (2, 3, 1, 1)

def mycomb(n,r):
    return (factorials[n] * pow(factorials[r],MOD-2,MOD) % MOD) * pow(factorials[n-r],MOD-2,MOD) % MOD

MOD = int(1e9 + 7)

factorials = []
factorials.append(1)
for i in range(1, W + H):
    factorials.append((factorials[i - 1] * i) % MOD)

r = 0
for i in range(H - A):
    combination = mycomb(B-1+i, B-1) * mycomb(W+H-B-i-2, W-B-1)
    r += int(combination)

print(r%MOD)
import sys
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = sys.maxsize
summoney = 0
for i in range(m):
  x,y,c = map(int,input().split())
  summoney = a[x-1] + b[y-1] - c
  ans = min(ans,summoney)
for i in range(a):
  for j in range(b):
    summoney = a[i] + a[j]
    ans = min(ans,summoney)
print(ans)

### FIXED CODE ###

a,b,m = map(int,input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
yasuiyo = min(al) + min(bl)
ans = []
for i in range(m):
  x,y,c = map(int,input().split())
  ans.append(al[x-1] + bl[y-1] - c)

print(min(min(ans),yasuiyo))
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1


### FIXED CODE ###

a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1
try :
    from math import gcd
except ImportError :
    from fractions import gcd


N = int(input())
A = list(map(int,input().split()))

X = [A[0]]
Y = [A[-1]]

for i in range(1,N) :
    X.append(gcd(X[i-1], A[i]))

for i in range(N-2,-1,-1) :
    Y.append(gcd(Y[i-1], A[i]))

Y = Y[::-1]

ans = 0

for i in range(N) :
    if i == 0 :
        ans = max(ans, Y[1])
    elif i == N-1 :
        ans = max(ans, X[N-2])
    else :
        ans = max(ans, gcd(X[i-1], Y[i+1]))

print(ans)


### FIXED CODE ###

try :
    from math import gcd
except ImportError :
    from fractions import gcd

N = int(input())
A = list(map(int,input().split()))

L = [0]
R = [0]

for i in range(N) :
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[N-1-i]))

M = []
R = R[::-1]
for i in range(N) :
    M.append(gcd(L[i], R[i+1]))


print(max(M))
a,b,k=map(int,input().split())
if a<k:
	b=max(b-(k-a),0)
	a=0
else:
	a=a-k
print(a,end=' ')
print(b)

### FIXED CODE ###

s,t=input().split()
print(t+s)
N,K = map(int,input().split())
A = list(map(int,input().split()))
town = 1
record = [1]
for i in range(K):
    town = A[town-1]
    if town in record:
        break
    record.append(town)
    
newrecord = record[record.index(town):]
roop = len(newrecord)
amari = K%roop

if K<=len(record):
    answer = record[amari]
else:
    answer = newrecord[amari-(len(record)-roop)]
print(answer)

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
town = 1
record = [1]
record2 = [0]*N
for i in range(N):
    town = A[town-1]
    if record2[town-1]==1:
        break
    record.append(town)
    record2[town-1] += 1
    
newrecord = record[record.index(town):]
roop = len(newrecord)
newK = K-(len(record)-roop)
if newK>=0:
    answer = newrecord[newK%roop]
else:
    answer = record[K]

print(answer)
for i in range(D):
  print(i%26+1)

### FIXED CODE ###

D = int(input())
for i in range(D):
  print(i%26+1)
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,10**6+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

def g(r,c):
  ans=0
  for i in range(1,c+1):
    ans+=cmb(r+i-1,i,mod)
  return ans

print((g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)+mod)%mod)

### FIXED CODE ###

def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,2*10**6+2):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

def g(r,c):
  ans=0
  for i in range(1,c+1):
    ans+=cmb(r+i-1,i,mod)
  return ans

print((g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)+mod)%mod)
N=int(input())
b=N%1000
if b=0:
  print(0)
else:
  print(1000-b)

### FIXED CODE ###

N=int(input())
b=N%1000
if b==0:
  print(0)
else:
  print(1000-b)
n = input()
n[4] = '8'
print(n)

### FIXED CODE ###

print('2018'+input()[4:])
no=int(input())
s=[*map(int,input().split())]
q=0
p=0
le=len(s)
if no==2:
    print(abs(s[1]-s[0]))
elif no==3:
    print(abs(s[2]-s[0]))
else:
    a=abs(s[1]-s[0])
    b=abs(s[2]-s[0])
    if no%2==0:
        for i in range(1,len(s)-1,2):
            q=q+abs(s[i]-s[i+2])
        q+=a
        for k in range(2,len(s)-2,2):
            p=p+abs(s[k]-s[k+2])    
        p+=b
        p=p+(abs((s[le-1])-(s[le-2])))
        print(min(q,p))
    else:
        for i in range(1,len(s)-2,2):
            q=q+abs(s[i]-s[i+2])
        q+=a
        q=q+(abs((s[le-1])-(s[le-2])))
        for k in range(2,len(s)-1,2):
            p=p+abs(s[k]-s[k+2])    
        p+=b
        print(min(q,p))

### FIXED CODE ###

no=int(input())
s=list(map(int,input().split()))
a=[0]
a.append(abs(s[1]-s[0]))
for i in range(2,no):
    a.append(min(abs((s[i]-s[i-1]))+a[i-1],abs((s[i]-s[i-2]))+a[i-2]))
print(a[-1])
while True:
    (n , x) = [int (i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n + 1 = 2):
        for b in range(a + 1, n + 1 - 1):
            for c in range(b + 1, n + 1 ):
                if (a + b + c) == x:
                    count += 1
    print(count)

### FIXED CODE ###

while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if x - (i + j + k) == 0:
                    count += 1
                if x - (i + j + k) < 0:
                    break
    print(count)
a, b = map(int, input().split())]
if a < b:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

a, b = map(int, input().split())
if a <= b:
  print("unsafe")
else:
  print("safe")
import numpy as np
N,*A=map(int,open(0).read().split())
A=(np.array(A)//400).astype("int32")

color_num=0

colors=np.zeros(9)

for a in A:
    colors[min(a,9)]+=1
c=np.count_nonzero(colors[:-1])

min_color_num = 1 if (c==0 and colors[-1]>0) else c
max_color_num = min(8,c+max(int(colors[-1]),0))

print(min_color_num,max_color_num)


### FIXED CODE ###

N,*A=map(int,open(0).read().split())

colors = [0 for i in range(8)]
tyty = 0

for a in A:
  c = a//400
  if c>=8:
    tyty+=1
  else:
    colors[c]+=1

cNum = 8-colors.count(0)
    
minC = max(cNum,1)
maxC = cNum+tyty

print(minC,maxC)
H, W, D = map(int, input().split())
A = [[] * W for i in range(H)]
dic = {}
for i in range(H):
    a = list(map(int, input().split()))
    A[i] = a
    for j in range(W):
        dic[a[j]] = (i + 1, j + 1)

rec = {}


def cal(L, R):
    global rec
    if L == R:
        return 0
    if (L, R) in rec:
        return rec[(L, R)]
    else:
        p = abs(dic[L + D][0] - dic[L][0]) + abs(dic[L + D][1] - dic[L][1])
        rec[(L, L + D)] = p
        rec[(L + D, R)] = cal(L + D, R)
        rec[(L, R)] = rec[(L, L + D)] + rec[(L + D, R)]
        return rec[(L, R)]


Q = int(input())
for i in range(Q):
    L, R = map(int, input().split())
    print(cal(L, R))

### FIXED CODE ###

from collections import defaultdict
H, W, D = map(int, input().split())
A = [[] * W for i in range(H)]
dic = {}
for i in range(H):
    a = list(map(int, input().split()))
    A[i] = a
    for j in range(W):
        dic[a[j]] = (i + 1, j + 1)

d = defaultdict(int)
for i in range(D + 1, H * W + 1):
    d[i] = d[i - D] + abs(dic[i][0] - dic[i - D][0]) + abs(dic[i][1] - dic[i - D][1])


Q = int(input())
for i in range(Q):
    L, R = map(int, input().split())
    print(d[R] - d[L])
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)[::-1]

ans = A[0]
cnt = 1
n = N - 2

while(1):
    
    ans += A[cnt]
    n -= 1
    if n == 0:  break
        
    ans += A[cnt]
    n -= 1
    if n == 0:  break
        
    cnt += 1
    
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)[::-1]

if N == 2:
    print(A[0])

else:
    ans = A[0]
    cnt = 1
    n = N - 2

    while(1):

        ans += A[cnt]
        n -= 1
        if n == 0:  break

        ans += A[cnt]
        n -= 1
        if n == 0:  break

        cnt += 1

    print(ans)
N = int(input())
S = str(input())
c = 0
for i in range(0,N):
    if S[i] == 'A' and S[i+1]== 'B' and S[i+2] == 'C':
        c += 1
print(c)

### FIXED CODE ###

N = int(input())
S = str(input())
c = 0
for i in range(0,N):
    if S[i:i+3] == 'ABC':
        c += 1
print(c)
X,K,D = [int(input()) for i in range(3)]
print(2)

### FIXED CODE ###

X,K,D = list(map(int, input().split()))
co,ans = divmod(abs(X),D)
if (K - co) > 0:
    if (K - co) % 2 == 0:
        pass
    else:
        ans = abs(ans) - D
else:
    ans = abs(X) - K*D

print(abs(ans))
N = int(input())
S = ""
while N:
     S = chr(N % (-2)) + S
     N /= (-2)
print(S)
    

### FIXED CODE ###

N = int(input())
S = ""
while N != 0:
    if N % 2 != 0:
        N -= 1
        S = "1" + S
    else:
        S = "0" + S
    N //= (-2)
print(S if S != "" else "0")
s=list(input())
count=0
if len(s)%2==0:
    for i in range(1,(len(s)//2)+1):
        if s[i-1]!=s[-i]:
            count+=1
else:
    for i in range(1,(len(s)//2))
        if s[i-1]!=s[-i]:
            count+=1
print(count)

### FIXED CODE ###

s=list(input())
count=0
for i in range(len(s)//2):
    if s[i]!=s[-i-1]:
        count+=1
print(count)
[s,t]=input().split();

cnt = 0;
for i in range(len(s)):
    if s[i] != t[i] :
        cnt=cnt+1;
        
print(cnt);

### FIXED CODE ###

#[s,t]=input().split();
s=input();
t=input();
cnt = 0;
for i in range(len(s)):
    if s[i] != t[i] :
        cnt=cnt+1;
        
print(cnt);
w, a, b = map(int, input().split())
ans = 0
if a < b:
  if a+w > b:
    ans = 0
  else:
    ans = b - a+w
else if a == b:
  ans = 0

else:
  if b+w > a:
    ans = 0
  else:
    ans = a - b+w

print(ans)


### FIXED CODE ###

w, a, b = map(int, input().split())
ans = 0
if a < b:
  if a+w > b:
    ans = 0
  else:
    ans = b - (a+w)
elif a == b:
  ans = 0
 
else:
  if b+w > a:
    ans = 0
  else:
    ans = a - (b+w)
 
print(ans)
import math
a, b = map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
print(lcm(a, b))

### FIXED CODE ###

a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b= b, a%b
    return a
def lcm(a, b):
    return (a * b) // gcd(a, b)
print(lcm(a, b))