Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

for i in range(M):
    A.extend([max(A)//2])
    A.remove(max(A))
print(sum(A))

### FIXED CODE ###

from heapq import heappop,heappush,heapify
n,m=map(int,input().split())
A=list(map(int,input().split()))
A_m=list(map(lambda x: -x,A))
heapify(A_m)
pop=lambda: -heappop(A_m)
push=lambda x: heappush(A_m,-x)
for _ in range(m):
    x=pop()
    push(x//2)
print(-sum(A_m))
### BUGGY CODE ###

import collections

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

cnt = collections.Counter(S)

ans_list = []

for key, value in cnt.items():
    if value == max(cnt.values()):
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')



### FIXED CODE ###

import collections

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

cnt = collections.Counter(S)
max_cnt = max(cnt.values())

ans_list = []

for key, value in cnt.items():
    if value == max_cnt:
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
for i in range(M):
    A[N-1]=A[N-1]//2
    A.sort()
print(sum(A))

### FIXED CODE ###

import heapq
N,M=map(int,input().split())
A=[-1*int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    a=-1*heapq.heappop(A)
    a=a//2
    heapq.heappush(A,-1*a)
print(-1*sum(A))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import numpy as np
import fractions
from functools import reduce

from copy import deepcopy


def gcd_list(nums):
    return reduce(fractions.gcd, nums)

def main():
    N = int(input())
    A = np.array(sorted(list(map(int, input().split()))))

    bools = np.ones(N, dtype=bool)

    ans = 0
    vals = []
    for i in range(N):
        A_cop = deepcopy(A)
        bl_cop = deepcopy(bools)

        fal = [i]
        bl_cop[fal] = False

        vals.append(gcd_list(A_cop[bl_cop]))

    print(max(vals))

main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
import fractions


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

    L_gcds = [0] * N
    L_gcd_tmp = L_gcds[0]
    for i in range(1, N):
        L_gcd_tmp = fractions.gcd(L_gcd_tmp, A[i-1])
        L_gcds[i] = L_gcd_tmp

    R_gcds = [0] * N
    R_gcd_tmp = R_gcds[0]
    for j in range(1, N):
        R_gcd_tmp = fractions.gcd(R_gcd_tmp, A[N-j])
        R_gcds[j] = R_gcd_tmp
    R_gcds.reverse()

    LR_gcds = [0] * N
    for k in range(0, N):
        LR_gcds[k] = fractions.gcd(L_gcds[k], R_gcds[k])

    print(max(LR_gcds))

main()
### BUGGY CODE ###

import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0

while True:
    for j in range(n):
        if math.ceil((h[j] - t * b) / (a - b)) > 0:
            X += math.ceil((h[j] - t * b) / (a - b))
    if X <= t:
        for j in range(n):
            if math.ceil((h[j] - (t - 1) * b) / (a - b)) > 0:
                Y += math.ceil((h[j] - (t - 1) * b) / (a - b))
        if Y > t - 1:
            print(t)
            exit()
        else:
            high = t - 1
    elif X > t:
        low = t + 1
    t = (low + high) // 2
    X = 0
    Y = 0

### FIXED CODE ###

import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
s = 0
while high - low >= 0:
    for j in range(n):
        X += max(0, math.ceil((h[j] - t * b) / (a - b)))
        #Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))
    if X == t:
        print(t)
        exit()
    elif X < t:
        high = t - 1
        """for j in range(n):
            Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))"""
    elif X > t:
        low = t + 1
    s = t
    t = (low + high) // 2
    X = 0
    Y = 0
for j in range(n):
  if math.ceil((h[j] - s * b) / (a - b)) > 0:
            Y += math.ceil((h[j] - s * b) / (a - b))
if Y <= s:
  print(s)
else:
  print(s + 1)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [-1 for _ in range(N)]

dp[0] = 0

for i in range(1, N):
    dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(1, min(K+1, i+1))])

print(dp[N-1])


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))

# dp = np.array([-1 for _ in range(N)])
dp = np.zeros(N, dtype=int)

dp[0] = 0

for i in range(1, N):
    start = max(0, i-K)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

print(dp[-1])
### BUGGY CODE ###

import sys
from copy import deepcopy as copy

def main():
    input = sys.stdin.readline
    n = int(input())
    a = [None]*n
    for i in range(n):
        a[i] = [int(x)-1 for x in input().split()]
    
    index = [0]*n
    search = [int(x) for x in range(n)]
    ans = 0
    while True:
        already = set()
        judge = True
        sub = []
        for key in search:
            if index[key] == n-1:
                continue
            key2 = a[key][index[key]]
            if index[key2] == n-1:
                continue
            if key != a[key2][index[key2]]:
                continue
            if key in already or key2 in already:
                continue
            already.add(key)
            already.add(key2)
            index[key] += 1
            index[key2] += 1
            sub.append(key)
            sub.append(key2)
            judge = False
        if judge:
            break
        ans += 1
        search = copy(sub)
        
    for value in index:
        if value != n-1:
            print(-1)
            sys.exit()
    print(ans)
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from copy import deepcopy as copy

def main():
    input = sys.stdin.readline
    n = int(input())
    a = [None]*n
    for i in range(n):
        a[i] = [int(x)-1 for x in input().split()]
    
    index = [0]*n
    search = [int(x) for x in range(n)]
    ans = 0
    while True:
        already = set()
        judge = True
        sub = []
        for key in search:
            if index[key] == n-1:
                continue
            key2 = a[key][index[key]]
            if index[key2] == n-1:
                continue
            if key != a[key2][index[key2]]:
                continue
            if key in already or key2 in already:
                continue
            already.add(key)
            already.add(key2)
            index[key] += 1
            index[key2] += 1
            sub.append(key)
            sub.append(key2)
            judge = False
        if judge:
            break
        ans += 1
        search = copy(sub)
        
    for value in index:
        if value != n-1:
            print(-1)
            sys.exit()
    print(ans)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from itertools import combinations
from decimal import Decimal

def expectval(num):
    up = [Decimal(str(n)) for n in range(1, num+1)]
    return sum(up) / Decimal(str(num))

n, k = tuple(map(int, input().split()))
l = list(map(int, input().split()))

ans = Decimal("-1")
for idx in range(len(l)):
    comb = l[idx:idx+k]
    _sum = 0
    for n in comb:
        _sum += expectval(n)
    if _sum > ans:
        ans = _sum

print("{:.12f}".format(ans))



### FIXED CODE ###

n, k = tuple(map(int, input().split()))
l = list(map(int, input().split()))

sums = [0 for _ in range(n+1)]
for i in range(n):
    exp = (1 + l[i]) / 2
    sums[i+1] = sums[i] + exp

ans = 0
for idx in range(n-k+1):
    diff = sums[idx+k] - sums[idx]
    ans = max(ans, diff)

print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

n = int(input())
A = inpl()

F = [1 for _ in range(n+2)]
f = 1

for x in range(1, n+2):
    f *= x
    F[x] = f
    
def comb(n, r):
    global F
    if n < r:
        return 0
    elif r <= 0:
        return 0
    else:
        return F[n]//(F[r] * F[n-r])


C = ["" for i in range(n+1)]

for l, a in enumerate(A):
    if type(C[a]) == int:
        i, j = C[a], l
        break
    else:
        C[a] = l

print(n)

for k in range(2, n+2):
    total = comb(n+1, k)
    b = comb(n+i-j, k-1)
    res = (total-b)%(10**9 + 7)
    print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

n = int(input())
A = inpl()
mod = 10**9 + 7

fct = [1]
inv = [1]

for i in range(1, n+2):
    fct.append((fct[-1]*i)%mod)
    inv.append((pow(fct[i], mod-2, mod)))

def comb(n, k):
    if k < 0 or k > n:
        return 0
    return (fct[n] * inv[n - k] * inv[k]) % mod    

C = ["" for i in range(n+1)]

for l, a in enumerate(A):
    if type(C[a]) == int:
        i, j = C[a], l
        break
    else:
        C[a] = l

print(n)

for k in range(2, n+2):
    total = comb(n+1, k)
    b = comb(n+i-j, k-1)
    res = (total-b)%(mod)
    print(res)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline


def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')

import re

def main():
	n=II()
	s=input()
	ans=0
	for i in range(1000):
		j=str(i).zfill(3)
		now=0
		for k in s:
			if j[now]==k:
				now+=1
			if now==3:
				ans+=1
				break



	print(ans)



















if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
#import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
#from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	s=input().rstrip().decode('utf-8')
	
	ans=0
	
	for a in range(10):
		a=str(a)
		aidx=s.index(a) if a in s else -1
		if aidx!=-1:
			ss=s[aidx+1:]
			for b in range(10):
				b=str(b)
				bidx = ss.index(b) if b in ss else -1
				if bidx != -1:
					sss=ss[bidx+1:]
					for c in range(10):
						c=str(c)
						if c in sss:
							ans+=1
	
	print(ans)
	
	
if __name__ == "__main__":
		main()
### BUGGY CODE ###

import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros((1<<M, 1<<N), dtype=np.int8)
    for i in range(1<<M):
        for j in range(1<<N):
            T[i][j] = bin(i&j).count("1")%2
    T = np.diff(T, axis=0)%2
    T = np.diff(T, axis=1)%2
    if not rev:
        T = np.transpose(T)
    for i in range(len(T)):
        print(*T[i], sep='')
resolve()

### FIXED CODE ###

import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros(1, dtype=np.int8)
    for i in range(N):
        T = np.tile(T, (2, 2))
        T[1<<i:, 1<<i:] ^= 1
    T = np.diff(T, axis=0)
    T = np.diff(T, axis=1)
    T = T[:, :(1<<M)-1]%2
    if rev:
        T = np.transpose(T)
    for t in T:
        print(''.join(t.astype(str)))
resolve()
### BUGGY CODE ###

A,B,K = map(int,input().split())
for i in range(K):
    if(A>=1):
        A-=1
    elif(B>=1):
        B-=1
    else:
        pass
print(A,B)

### FIXED CODE ###

A,B,K = map(int,input().split())
if(A-K<=0):
    if(B-K+A<=0):
        print(0,0)
    else:
        print(0,B-K+A)
else:
    print(A-K,B)
### BUGGY CODE ###

N = int(input())
S = list(input())

delKeta = N-3
Vall = []
ans=[]
for V3 in range(10):
    for V2 in range(10):
        for V1 in range(10):
            Vall.append([V1, V2, V3])

for V in Vall:
    tmp = ''
    i = 0
    j = 0
    while i < N:
        if(V[j] == int(S[i])):
            tmp+=S[i]
            j += 1
        if(j==3):
            break
        i+=1
    if(len(tmp) == 3):
        ans.append(tmp)

print(len(set(ans)))


### FIXED CODE ###

N = int(input())
S = list(map(int,input()))
count = 0

for x100 in range(10):
    if x100 in S[:N-2]:
        ind_100 = S.index(x100)
        
        for x10 in range(10):
            if x10 in S[ind_100+1:N-1]:
                ind_10 = S[ind_100+1:N-1].index(x10) + ind_100 + 1
                
                for x1 in range(10):
                    if x1 in S[ind_10 + 1:]:
                        count += 1
print(count)
### BUGGY CODE ###

S = input()
boundaries = []
boundaries_RL = []
boundaries_LR = []
children = [0] * len(S)
append = boundaries.append
RL_append = boundaries_RL.append
LR_append = boundaries_LR.append

for i in range(1, len(S)):
    if S[i-1] == 'R' and S[i] == 'L':
        append(i)
        RL_append(i)
    elif S[i-1] == 'L' and S[i] == 'R':
        LR_append(i)
        append(i)

for j in range(len(boundaries)):
    if boundaries[j] in boundaries_LR:
        continue
    else:  # boundaries[j]は、RLとなっているところの、Lのindex
        '''group1: Rより左側のchildren'''
        if j == 0:
            group1 = boundaries[j]
        else:
            group1 = boundaries[j] - boundaries[j-1]
        if group1 % 2 == 0:
            children[boundaries[j]] += group1 // 2
            children[boundaries[j]-1] += group1 // 2
        else:
            children[boundaries[j]-1] += group1 // 2 + 1
            children[boundaries[j]] += group1 // 2
        '''group2: Lより右側のchildren'''
        if j == len(boundaries)-1:
            group2 = len(S) - boundaries[j]
        else:
            group2 = boundaries[j+1] - boundaries[j]
        if group2 % 2 == 0:
            children[boundaries[j]] += group2 // 2
            children[boundaries[j]-1] += group2 // 2
        else:
            children[boundaries[j]] += group2 // 2 + 1
            children[boundaries[j]-1] += group2 // 2

print(*children)


### FIXED CODE ###

S = input()


def solve(s):
    buf = [1] * len(s)

    for i in range(len(buf) - 2):
        if s[i] == "R" and s[i + 1] == "R":
            buf[i+2] += buf[i]
            buf[i] = 0

    for i in range(len(buf) - 1, 1, -1):
        if s[i] == "L" and s[i - 1] == "L":
            buf[i-2] += buf[i]
            buf[i] = 0

    return " ".join(map(str, buf))


print(solve(S))
### BUGGY CODE ###

mod=10**9+7
def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out

N=int(input())
A=list(map(int, input().split()))
ma=max(A)
keta=1
while ma>=2**keta:
  keta+=1
  
onekazu=[0 for i in range(keta)]
k=str(keta)
for i in range(N):
  temp=format(A[i], '0'+str(k)+'b')
  for j in range(keta):
    onekazu[-1-j]+=int(temp[-1-j])
    
out=0
for i in range(keta):
  temp=onekazu[i]*(N-onekazu[i])%mod
  temp*=(2**(keta-1-i))%mod
  out+=temp
  out%=mod
  
print(out)

### FIXED CODE ###

mod=10**9+7
def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out

N=int(input())
A=list(map(int, input().split()))
ma=max(A)
keta=1
while ma>=2**keta:
  keta+=1
  
onekazu=[0 for i in range(keta)]
k=str(keta)
for i in range(N):
  temp=format(A[i], '0'+str(k)+'b')
  onekazu=[onekazu[j]+1 if temp[j]=='1' else onekazu[j] for j in range(keta)]
    
out=0
out=sum([(onekazu[i]*(N-onekazu[i])%mod)*(2**(keta-1-i))%mod for i in range(keta)])
out%=mod  
print(out)
### BUGGY CODE ###

n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))
for i in T:
  if i not in D:
    print("NO")
    exit()
  D.remove(i)
print("YES")

### FIXED CODE ###

from collections import Counter
n = int(input())
D = Counter(input().split())
m = int(input())
T = Counter(input().split())
for i in T.keys():
  if i not in D or D[i] < T[i]:
    print("NO")
    exit()
print("YES")
### BUGGY CODE ###

# coding: utf-8
N=int(input())
A=list((map(int,input().split())))
A.insert(0,0)

d=[]
skip_d=[]

for i in range(N):
    d.append(abs(A[i+1]-A[i]))
    if i<N-1:
        skip_d.append(abs(A[i+2]-A[i]))
    else:
        skip_d.append(abs(A[0]-A[i]))

d.append(abs(A[-1]))


for i in range(N):
    ans=sum(d)-(d[i]+d[i+1])+skip_d[i]
    
    print(ans)

### FIXED CODE ###

# coding: utf-8
N=int(input())
A=list((map(int,input().split())))
A.insert(0,0)

d=[]
skip_d=[]

for i in range(N):
    d.append(abs(A[i+1]-A[i]))
    if i<N-1:
        skip_d.append(abs(A[i+2]-A[i]))
    else:
        skip_d.append(abs(A[0]-A[i]))

d.append(abs(A[-1]))

sum_d=sum(d)

for i in range(N):
    ans=sum_d-(d[i]+d[i+1])+skip_d[i]
    
    print(ans)
### BUGGY CODE ###

N = int(input())
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
            
while len(M) > 1:
    M = [mini] + [x-mini for x in M[1:] if x % mini != 0]
    M.sort()
    if 1 in M:
        mini=1
        break
    mini = min(mini,M[0])
print(mini)    


### FIXED CODE ###

N = int(input())
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
            
while len(M) > 1:
    M = [mini] + [x%mini for x in M[1:] if x % mini != 0]
    M.sort()
    if 1 in M:
        mini=1
        break
    mini = min(mini,M[0])
print(M[0])
### BUGGY CODE ###

import fractions
N=int(input())
T,A=map(int,input().split())
for i in range(1,N):
    nT,nA=map(int,input().split())
    m,p=nT,nA
    while(nT<T or nA<A):
        nT+=m;nA+=p
    T,A=nT,nA
print(T+A)

### FIXED CODE ###

import fractions
N=int(input())
T,A=map(int,input().split())
for i in range(1,N):
    nT,nA=map(int,input().split())
    if(nT>=T and nA>=A):
        T,A=nT,nA
        continue
    pT,pA=T//nT,A//nA
    if(T%nT!=0):
        pT+=1
    if(A%nA!=0):
        pA+=1
    T,A=nT*max(pT,pA),nA*max(pT,pA)
print(T+A)
### BUGGY CODE ###

N=int(input())
listn = list(map(int,input().split()))
moji = "YES"
for i in range(len(listn)):
  for j in range(i+1,len(listn)):
    if listn[i] == listn[j]:
      moji = "NO"
      break
      
    else:
      continue
      
print(moji)

### FIXED CODE ###

N=int(input())
listn = list(map(int,input().split()))
setn = set(listn)

if len(listn) == len(setn):
  print("YES")
else:
  print("NO")
### BUGGY CODE ###

from collections import Counter


y = 2019
S = [s for s in input()]
N = len(S)
T = [0] * N

for i in range(N):
    T[i] = int(''.join(S[i:N])) % y

cnt = 0
for t, c in Counter(T).items():
    if t == 0:
        cnt += 1
        continue
    cnt += c * (c - 1) // 2
    
print(cnt)

### FIXED CODE ###

from queue import deque
 
    
S = deque(input())
y = 2019
U = [0] * y
t = 0
U[0] = 1
k = 1

for s in reversed(S):
    t = t + int(s) * k
    t %= y
    U[t] += 1
    k *= 10
    k %= y

cnt = 0
for u in U:
    cnt = cnt + u * (u - 1) // 2

print(cnt)
### BUGGY CODE ###

import sys
h, n = map(int, input().split())
A = [0] * n
B = [0] * n
for i in range(n):
    A[i], B[i] = map(int, input().split())
min_hp = h
max_hp = h + max(A)

dp = [sys.maxsize] * (max_hp + 1)
dp[0] = 0

for i in range(0, min_hp + 1):
    for j in range(n): # type of spell
        next_index = min(i + A[j], min_hp)
        dp[next_index] = min(dp[next_index], dp[i] + B[j])

# dp = [[sys.maxsize] * (max_hp + 1) for i in range(n + 1)]
# for i in range(n + 1):
#     for j in range(min(A[1:]) + 1):
#         dp[i][j] = min(B[1:])
#
# for i in range(1, n + 1):
#     for j in range(1, max_hp + 1):
#         dp[i][j] = dp[i-1][j] if A[i] > j else min(dp[i-1][j-A[i]] + B[i], dp[i-1][j])
#         # dp[i][j] = dp[i][j-1] + B[i] if A[i] > j else min(dp[i][j-A[i]] + B[i], dp[i][j-1] + B[i])
print(min(dp[h:]))


### FIXED CODE ###

H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
max_a = max(a for a, b in ab)
dp = [0]*(H+max_a)
for i in range(1, H+max_a):
    dp[i] = min(dp[i-a]+b for a, b in ab)
print(dp[H])
### BUGGY CODE ###

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

ans = float("inf")
for loop in range(0, N+1):
  mxcnt = loop
  NC=A[:]
  for i in range(2*N+1):
    if i >=N: i%=N    
    pcnt=1
    pi=(i+1)%N
    v=A[i]
    while pcnt<=mxcnt:
      if v>=NC[pi]: break   
      NC[pi]=v
      pcnt+=1
      pi=(pi+1)%N
    tmp = (mxcnt)*X + sum(NC)
    ans = min(tmp, ans)
    # print("loop: ", loop, NC)
print(ans)
exit(0)


### FIXED CODE ###

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

ans = float("inf")
bik = A[:]

get_idx_back = lambda idx,b: idx-b if idx>=b else idx+N-b

for loop in range(0, N+1):
  if loop == 0:
      bik = A[:]
  else: 
      for i in range(N):
          bik[i] = min(bik[i], A[ get_idx_back(i, loop) ])

  tmp = (loop)*X + sum(bik)

  ans = min(tmp, ans)
print(ans)
exit(0)
### BUGGY CODE ###

import random
N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
#N=2*10**5
#a=[random.randrange(2**30) for i in range(N)]
#b=[random.randrange(2**30) for i in range(N)]

for k in range(N):
    x=a[k]^b[0]
    flag=1
    for line in range(1000):
        i=random.randrange(N)
        if a[(k+i)%N]^b[i]!=x:
            flag=0
            break
    if flag==1:
        print(k,x)


### FIXED CODE ###

#https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + s[i]) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod
N=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[a[i%N]^a[(i+1)%N] for i in range(2*N)]
d=[b[i]^b[(i+1)%N] for i in range(N)]
P=RollingHash(c,97,10**9+7)
Q=RollingHash(d,97,10**9+7)

for k in range(N):
    if P.get(k,k+N)==Q.get(0,N):
        x=b[0]^a[k]
        print(k,x)
### BUGGY CODE ###

#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    SUGOI=[False]*(10**6+1)
    for a in A:
        for j in range(2*a,10**6+1,a):
            SUGOI[j]=True
    cnt=0
    for a in A:
        if A.count(a)==1 and SUGOI[a]==False:
            cnt+=1
    print(cnt)
    
    
if __name__=="__main__":
    main()


### FIXED CODE ###

#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    cho=set()
    for i in range(len(A)-1):
        if A[i]==A[i+1]:
            cho.add(A[i])
    A=list(set(A))
    SUGOI=[False]*(10**6+1)
    for a in A:
        for j in range(2*a,10**6+1,a):
            SUGOI[j]=True
    cnt=0
    A=list(set(A)-cho)
    for a in A:
        if SUGOI[a]==False:
            cnt+=1
    print(cnt)
    
    
if __name__=="__main__":
    main()