CodeEff/ECCO huggingface dataset:
# Original solution
import itertools
n,k=list(map(int,input().split()))
price=list(map(int,input().split()))

n_list=[]
for com in itertools.combinations(price,k):
    s=sum(com)
    n_list.append(s)
print((min(n_list)))


# Optimized solution
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
print((sum(sorted(p)[:K])))
# Original solution
import itertools
import sys

input = sys.stdin.readline

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
l = [sum(i) for i in itertools.combinations(p, K)]
print((min(l)))

# Optimized solution
N, K = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))
print((sum(p[:K])))
# Original solution
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

p.sort()
ans = 0
for i in range(K):
    ans += p[i]
print(ans)


# Optimized solution
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

p.sort()
print((sum(p[: K])))
# Original solution
# import sys
# input = sys.stdin.readline
# import re
import itertools

def main():
    n, k = input_list()
    p = input_list()

    pp = []
    for v in itertools.combinations(p, k):
        pp.append(sum(v))
    print((min(pp)))

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

def input_list():
    return list(map(int, input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    main()


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

def main():
    n, k = input_list()
    p = input_list()

    p.sort()
    print((sum(p[:k])))

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

def input_list():
    return list(map(int, input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = list(map(int,S().split()))
p = LI()
p = sorted(p)

ans = 0
for i in range(K):
    ans += p[i]

print(ans)

# Optimized solution
import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def S(): return sys.stdin.readline().rstrip()

N,K = list(map(int,S().split()))
p = LI()
p = sorted(p)

print((sum(p[i] for i in range(K))))
# Original solution
#!/usr/bin/env python3
import sys
from itertools import chain
from itertools import combinations as comb
# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    answer = min(list(map(sum, comb(p, K))))
    return answer

def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, K, p = map(int, line.split())
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, p)
    print(answer)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    p = sorted(p)
    return sum(p[:K])


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, K, p = map(int, line.split())
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, p)
    print(answer)


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

total =[]

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

for i in itertools.combinations(p, K):
    total.append(sum(i))

print((min(total)))


# Optimized solution
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

m = []
for i in range(K):
    a = min(p)
    m.append(a)
    p.remove(a)

print((sum(m)))
# Original solution
import itertools

N,K = list(map(int,input().split()))
p =  list(map(int,input().split()))
ans = 1000000

for v in itertools.combinations(p, K):
    tmp = sum(v) 
    if ans > tmp:
        ans = tmp

print(ans)

# Optimized solution
N,K = list(map(int,input().split()))
p =  list(map(int,input().split()))

ans=0
p.sort()
for i in range(K):
    ans += p[i]
print(ans)
# Original solution
import itertools
N, K= list(map(int,input().split()))
p = list(map(int, input().split()))
ans = 1000000
for i in itertools.combinations(p, K):
    s = sum(i)
    ans = min(ans, s)
print(ans)


# Optimized solution
import itertools
N, K= list(map(int,input().split()))
p = list(map(int, input().split()))
p.sort()
ans = sum(p[:K])
print(ans)
# Original solution
import itertools

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

prices = list(map(int, input().split()))

ans = 1000000

for i in itertools.permutations(prices, k):
    ans = min(ans, sum(i))

print(ans)

# Optimized solution
import itertools

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

prices = list(map(int, input().split()))

prices = sorted(prices)

print((sum(prices[:k])))
# Original solution

n,k=list(map(int,input().split()))
t=list(map(int,input().split()))
t.sort()
ans=0
for i in range(k):
	ans+=t[i]
print(ans)


# Optimized solution
n,k=list(map(int,input().split()))
t=[int(i) for i in input().split()]
t.sort()
print((sum(t[:k])))
# Original solution
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

import itertools
c = itertools.combinations(p, K)
L = [sum(item) for item in c]
print((min(L)))

# Optimized solution
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

p.sort()
print((sum(p[:K])))
# Original solution
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = 0
result = []
while count < a[1]:
  result.append(min(b))
  b.remove(min(b))
  count += 1
  
print((sum(result)))

# Optimized solution
n, k = list(map(int,input().split()))
p = list(map(int, input().split()))
ans = 0
for _ in range(k):
  m = min(p)
  ans += m
  p.remove(m)
  
print(ans)
# Original solution
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()

    print((sum(a[:k])))


if __name__ == '__main__':
    main()


# Optimized solution
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

a.sort()
ans = sum(a[:k])
print(ans)
# Original solution
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort()
ans = 0
for p in P[:K]:
    ans += p
print(ans)


# Optimized solution
N, K = list(map(int, input().split()))
P = sorted(list(map(int, input().split())))
print((sum(P[:K])))
# Original solution
from itertools import product, permutations, combinations
import math
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

ans = math.inf
for pt in combinations(P, K):
    ans = min(ans, sum(pt))

print(ans)
exit()


# Optimized solution
from itertools import product, permutations, combinations
import math
N, K = list(map(int, input().split()))
P = list(sorted((list(map(int, input().split())))))

print((sum([P[i] for i in range(K)])))
exit()
# Original solution
import itertools
 
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = [1000000000000]
for l in list(itertools.combinations(p, K)):
  sums = sum(list(l))
  if sums <= min(lists):
    lists.append(sums)

print((min(lists)))


# Optimized solution
S = list(map(int, input().strip().split()))
N = S[0]
K = S[1]
p = list(map(int, input().strip().split()))
lists = []
for l in range(K):
  lists.append(min(p))
  p.remove(min(p))
  
print((sum(lists)))
# Original solution
import itertools

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

minprice = sum(plist)
sumlist =[]
for v in itertools.permutations(plist, K):
  sumlist.append(sum(v))
print((min(sumlist)))

# Optimized solution
N,K = list(map(int,input().split()))
plist = list(map(int,input().split()))

plist.sort()
sum = 0
for i in range(K):
  sum+=plist[i]
print (sum)
# Original solution
import itertools
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))
Sigmas = []
for M in itertools.combinations(P,K):
    Sigma = sum(list(M))
    Sigmas.append(Sigma)
print((min(Sigmas)))


# Optimized solution
import itertools
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))
Sigma = sorted(P,reverse = False)
print((sum(Sigma[:K])))
# Original solution
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))

cheap = []

for m in range(k):
    for i in range(len(l)):
        flag = False
        for j in range(len(l)):
            if l[i] > l[j]:
                flag = True
                break
        if flag == False:
            cheap.append(l[i])
            l.remove(l[i])
            break

print((sum(cheap)))

# Optimized solution
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))

l.sort()

cheap = l[:k]

print((sum(cheap)))
# Original solution
n, k = list(map(int, input().split()))
p = sorted(list(map(int, input().split())))
print((sum(p[:k])))

# Optimized solution
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, k = list(map(int, input().split()))
    p = sorted(list(map(int, input().split())))
    print((sum(p[:k])))


if __name__ == '__main__':
    main()
# Original solution
N,K=list(map(int,input().split()))
p=sorted(list(map(int,input().split())))
print((sum(p[:K])))


# Optimized solution
n,k=list(map(int,input().split()))
p=sorted(list(map(int,input().split())))
print((sum(p[:k])))
# Original solution
NK = input().split()
n = int(NK[0])
k = int(NK[1])
arr = list(map(int, input().split()))
arr.sort()
print((sum(arr[0:k])))


# Optimized solution
n, k = input().split()
p = list(map(int, input().split()))
p = sorted(p)
ans = 0
for i in range(int(k)):
    ans += p[i]
print(ans)
# Original solution
import itertools

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

ans = 1000*1000

for i in itertools.permutations(p_list,k):
    ans = min(ans, sum(i))

print(ans)

# Optimized solution
n, k = list(map(int, input().split()))
p_list = list(map(int, input().split()))

p_list_min = sorted(p_list)
ans = sum(p_list_min[0:k])

print(ans)
# Original solution
n,k=list(map(int,input().split()))
p=list(map(int,input().split()))

i=0
while True:
    if len(p)==1:
        break
    if p[i]<=p[i+1]:
        i+=1
    else:
        a=p[i]
        p[i]=p[i+1]
        p[i+1]=a
        i=0
    if i==len(p)-1:
        break

ans=0
for i in range(k):
    ans+=p[i]
print(ans)


# Optimized solution
n,k=list(map(int,input().split()))
p=list(map(int,input().split()))

ans=0
if n!=1:
    for i in range(k):
        min=p[i]
        for j in range(i+1,n):
            if min>p[j]:
                min=p[j]
                p[j]=p[i]
                p[i]=min
        ans+=min
else:
    ans=p[0]
print(ans)
# Original solution
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    n,k = list(map(int,input().split()))
    p = list(map(int,input().split()))
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)

# Optimized solution
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def main():
    n,k = list(map(int,input().split()))
    p = list(map(int,input().split()))
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)
 
if __name__ == "__main__":
    main()
# Original solution
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))

p.sort()
result = 0
for i in range(k):
    result += p[i]

print(result)


# Optimized solution

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

p.sort()

print((sum(p[:k])))
# Original solution
import itertools

n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = 10**19

for i in itertools.permutations(p,k):
    s = sum(i)
    if s < ans:
        ans = s

print(ans)

# Optimized solution
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))

q = sorted(p)

print((sum(q[:k])))
# Original solution
from itertools import combinations
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

buy = list(combinations(P, K))
sum_money = [sum(b) for b in buy]
print((min(sum_money)))

# Optimized solution
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort()
print((sum(P[:K])))
# Original solution
n,k=list(map(int,input().split()))
p=list(map(int,input().split()))

count=0
p.sort()
for i in range(k):
  count+=p[i]
  
print(count)

# Optimized solution
n,k=list(map(int,input().split()))
p=sorted(list(map(int,input().split())))
print((sum(p[:k])))
# Original solution
from itertools import combinations as comb

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

min=None
for x in comb(list(range(n)),k):
    sm=0
    for i in range(len(x)):
        sm+=p[x[i]]
    if not min : min=sm
    if sm<min : min=sm
print(min)

# Optimized solution
n,k=list(map(int,input().split()))
p=list(map(int,input().split()))
p.sort()
sm=sum(p[:k])
print(sm)
# Original solution
from itertools import combinations

n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
p.sort()

com = list(combinations(p,k))
ans = list(map(sum,com))
print((min(ans)))

# Optimized solution
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
p.sort()
ans = 0

for i in range(k):
    ans += p[i]
    i += 1

print(ans)
# Original solution
import itertools


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

  min_ = float('inf')

  all_ = list(range(N))
  for items in itertools.combinations(all_, K):
    sum_ = sum([P[i] for i in items])
    min_ = min(min_, sum_)

  print(min_)


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

# Optimized solution
def main():
  N, K = list(map(int, input().split()))
  P = list(map(int, input().split()))

  P.sort()
  print((sum(P[:K])))


if(__name__ == '__main__'):
  main()
# Original solution
import itertools
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
t = list(list(itertools.combinations(A,K)))
ans = sum(t[0])
for i in t:
    ans = min(ans,sum(i))
print(ans)


# Optimized solution
N,K = list(map(int,input().split()))
A = sorted(map(int,input().split()))
print((sum(A[:K])))
# Original solution
N,K=list(map(int,input().split()))
P=sorted(map(int,input().split()))
r=0
for i in range(K):
  r+=P[i]
print(r)

# Optimized solution
N,K=list(map(int,input().split()))
P=sorted(map(int,input().split()))
print((sum(P[:K])))
# Original solution
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

ans = float("inf")
for i in range(1 << len(P)):
    sum = 0
    cnt = 0
    for j in range(len(P)):
        if (i >> j) & 1 == 1:
            sum += P[j]
            cnt += 1
            if cnt == K:
                ans = min(ans, sum)
print(ans)


# Optimized solution
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

P = sorted(P)

print((sum(P[:K])))
# Original solution
x,y = list(map(int,input().split()))
n = sorted(list(map(int,input().split())))
print((sum(n[:y])))

# Optimized solution
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
print((sum(a[:k])))
# Original solution
N,K=list(map(int,input().split()))
p=sorted(map(int,input().split()))
print((sum(p[:K])))

# Optimized solution
N, K = list(map(int, input().split()))
p = sorted(map(int, input().split()))
print((sum(p[0:K])))
# Original solution
N, K = list(map(int, input().split()))
p = sorted(map(int, input().split()))
print((sum(p[:K])))

# Optimized solution
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
print((sum(sorted(p)[0:K])))
# Original solution
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 
import itertools

l=[]
for v in itertools.combinations(B, A[1]):
  l.append(sum(v))
  
print((min(l)))

# Optimized solution
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 

B.sort()

print((sum(B[:A[1]])))
# Original solution
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return list(map(int,input().split()))
def ii():
    return int(eval(input()))
sys.setrecursionlimit(10**9)

N,K = mips()
ans = 10**9
P = [p for p in mips()]
L = list(map(list,itertools.permutations(P,K)))
for el in L:
    ans = min(ans,sum(el))
print(ans)
    


# Optimized solution
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return list(map(int,input().split()))
def ii():
    return int(eval(input()))
sys.setrecursionlimit(10**9)

N,K = mips()
ans = 0
P = [p for p in mips()]
P.sort()
for i in range(K):
    ans += P[i]
print(ans)
# Original solution
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
s = 0
for i in range(k):
    s += a[i]
print(s)

# Optimized solution
n,k = list(map(int,input().split()))
p = [int(x) for x in input().split()]
p.sort()
s = 0
for i in range(k):
    s+=p[i]
print(s)
# Original solution
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
ans = 0
for i in range(k):
    ans += p[i]
print(ans)


# Optimized solution
n, k = list(map(int, input().split()))
ps = list(map(int, input().split()))
ps.sort()
ans = sum(ps[:k])
print(ans)
# Original solution
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

n, k = list(map(int, input().split()))
nums = list(map(int, stdin.readline().split()))
nums.sort()
print((sum(nums[:k])))


# Optimized solution
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))

print((sum(sorted(nums)[:k])))
# Original solution
from itertools import combinations
n,k = list(map(int,input().split()))
list1 = list(map(int,input().split()))
list2  = []
for i in combinations(list1,k) :
    list2.append(sum(i))
print((min(list2)))

# Optimized solution
from itertools import combinations
n,k = list(map(int,input().split()))
list1 = list(map(int,input().split()))
print((sum(sorted(list1)[:k])))
# Original solution
import itertools

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

# tmp = itertools.combinations_with_replacement(P, K)
tmp = itertools.combinations(P, K)

hoge = []
for i in tmp:
    hoge.append(sum(i))

print((min(hoge)))


# Optimized solution
# import itertools

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

# tmp = itertools.combinations_with_replacement(P, K)
# tmp = itertools.combinations(P, K)

P.sort()
print((sum(P[0:K])))

# hoge = []
# for i in tmp:
#     hoge.append(sum(i))

# print(min(hoge))
# Original solution
n, k = list(map(int, input().split()))
price_list = list(map(int, input().split()))

sum = 0
min_index = 0

for i in range(k):
    min_index = price_list.index(min(price_list))
    sum += price_list.pop(min_index)

print(sum)

# Optimized solution
n, k = list(map(int, input().split()))
price_list = list(map(int, input().split()))

price_list.sort()
sum = 0

for i in range(k):
    sum += price_list[i]

print(sum)
# Original solution
import itertools
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

min_ = float('inf')
combi = itertools.combinations(p, k)
for c in combi:
    min_ = min(min_, sum(c))
    
print(min_)

# Optimized solution
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

p = sorted(p)
ans = sum(p[:k])
print(ans)
# Original solution
from itertools import combinations
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))

res = 10**16
for t in combinations(list(range(N)), K):
  res = min(res, sum([P[i] for i in t]))
print(res)


# Optimized solution
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))
P.sort()

print((sum(P[:K])))
# Original solution
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
print((sum(a[:k])))

# Optimized solution
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return list(map(int,sys.stdin.buffer.readline().split()))
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n,k = Mi();
p = Li();
p.sort();
print((sum(p[:k])))
# Original solution
from itertools import combinations

N,K=list(map(int, input().split()))
P=list(map(int, input().split()))
ans=float('INF')
L=list(combinations(list(range(N)),K))
for a in L:
    sums=0
    for i in range(K):
        sums+=P[a[i]]
    # print(sums)
    ans=min(ans,sums)
print(ans)

# Optimized solution
N,K=list(map(int, input().split()))
P=list(map(int, input().split()))
P.sort()
L=P[:K]
print((sum(L)))
# Original solution
import itertools
N,K,*p = list(map(int,open(0).read().split()))
print((min([sum(x) for x in itertools.combinations(p,K)])))

# Optimized solution
N,K,*p = list(map(int,open(0).read().split()))
p.sort()
print((sum(p[:K])))
# Original solution
N,K = list(map(int,input().split()))
P = sorted(list(map(int,input().split())))
print((sum(P[:K])))

# Optimized solution
N,K = list(map(int,input().split()))
print((sum(sorted(list(map(int,input().split())))[:K])))
# Original solution
def resolve():
    import itertools
    N, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    minA = 10**9
    for a in itertools.combinations(A, K):
        minA = min(minA, sum(a))
    print(minA)

resolve()


# Optimized solution
def resolve():
    N, K = [int(i) for i in input().split()]
    A = sorted([int(i) for i in input().split()])
    sumA = 0
    for a in A[:K]:
        sumA += a
    print(sumA)


resolve()
# Original solution
# -*- coding: utf-8 -*-

import io
import sys
import math

def solve(n,k,p_lst):
    pp_lst = sorted(p_lst)
    return sum(pp_lst[0:k])

def main():
    n,k = list(map(int, input().split()))
    p_lst = list(map(int, input().split()))
    
    ans = str(solve(n,k,p_lst))
    print(ans)

    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
5 4
50 100 80 120 80
"""
_EXPECTED = """\
210
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

# Optimized solution
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
print((sum(a[:k])))