Problem:
 Score : 200 points    Problem Statement A shop sells N kinds of fruits, Fruit 1, \ldots, N , at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)  Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.      Constraints  1 \leq K \leq N \leq 1000  1 \leq p_i \leq 1000  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K  p_1  p_2  \ldots  p_N       Output Print an integer representing the minimum possible total price of fruits.        Sample Input 1 5 3
50 100 80 120 80      Sample Output 1 210  This shop sells Fruit 1 , 2 , 3 , 4 , and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.  The minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1 , 3 , and 5 .       Sample Input 2 1 1
1000      Sample Output 2 1000

Solution (Python):

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

p.sort()

print(sum(p[:k]))

Solution (Python):
N, K = map(int, input().split())
PRICE = sorted(list(map(int, input().split())))
print(sum(PRICE[:K]))

Solution (Python):
N,K=list(map(int, input().split()))
P=list(map(int, input().split()))
P.sort()
L=P[:K]
print(sum(L))

Solution (Python):
N,K=map(int,input().split())
P=list(input().split())
Ps=[int(s) for s in P]
Ps.sort()
Psx=Ps[:K]


print(sum(Psx))

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

P.sort()

print(sum(P[:K]))

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

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

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k, *p = map(int, read().split())
    p.sort()
    r = sum(p[:k])
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
print(sum(l[:k]))

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

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

min=p[0]
for i in range(n-1) :
    for j in range(n-1-i) :
        if(p[i]>p[j+i+1]) :
            t=p[i]
            p[i]=p[j+i+1]
            p[j+i+1]=t
    
sum=0
for i in range(k) :
    sum+=p[i]

print(sum)

Solution (Python):
N, K = input().split(" ")

price = input().split(" ")
list1 = []

for j in price:
    list1.append(int(j))

list1 = list1[:int(N)]
list1.sort()

list2 = list1[:int(K)]

summ = 0
for i in list2[:int(K)]:
    summ += int(i)

print(summ)

Solution (Python):
N,K=map(int,input().split())
P=sorted(list(map(int,input().split())))
print(sum(P[:K]))

Solution (Python):
n,k = map(int, input().split())

p = list(map(int,input().split()))
p_sort = sorted(p)

print(sum(p_sort[:k]))

Solution (Python):
N, K = map(int, input().split())
p = map(int, input().split())
print(sum(sorted(p)[:K]))

Solution (Python):
N, K = map(int, input().split())
prices = list(map(int, input().split()))

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

Solution (Python):
from itertools import product, permutations, combinations
import math
N, K = map(int, input().split())
P = list(sorted((list(map(int, input().split())))))

print(sum([P[i] for i in range(K)]))
exit()

Solution (Python):
n, k = map(int, input().split())
p = sorted(map(int, input().split()))
i = 0
for j in range(k):
    i = i + p[j]
print(i)

Solution (Python):
n,k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
c = 0
i = 0
while i < k:
  c += l[i]
  i += 1
print(c)

Solution (Python):
n, k = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = sorted(p1)
p3 = sum(p2[:k])
print(p3)

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
n,k = map(int, input().split())
price_list = [int(x.strip()) for x in input().split()]
sorted_list = sorted(price_list)
ans = sum(sorted_list[:k])
print(ans)

Solution (Python):
N,K =  [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

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

Solution (Python):

N,K = map(int,input().split())
p = sorted(list(map(int, input().split())))
ans = sum(p[:K])
print(ans)

Solution (Python):
N,K = map(int,input().split())
P = list(map(int,input().split()))
a = 0
for i in range(K):
  a += min(P)
  del P[P.index(min(P))]
print(a)

Solution (Python):
N, K = input().split()
N, K = int(N), int(K)
p = list(map(int, input().split()))
sum = 0
for i in range(K):
  min_price = min(p)
  p.remove(min(p))
  sum+= min_price
print(sum)

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

p_s = sorted(p)

print(sum(p_s[:k]))

Solution (Python):
N, K = map(int, input().split())
P = [int(x) for x in input().split()]
P.sort()
print(sum(P[0:K]))

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
Ans = 0

p.sort()

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

print(Ans)

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
money = 0

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

print(money)

Solution (Python):
NK = input().split()
Pn = input().split()
for i in range(int(NK[0])):
    Pn[i] = int(Pn[i])
Pn.sort()
s = 0
for i in range(int(NK[1])):
    s += Pn[i]
print(s)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
ans = sum(P[:K])
print(ans)

Solution (Python):
n, k = [int(x) for x in input().split()]
p_list = sorted([int(x) for x in input().split()])
print(sum(p_list[:k]))

Solution (Python):
N, K = map(int, input().split())

p = input().split()
p = [int(s) for s in p]
p.sort()

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

Solution (Python):
n,k = list(map(int,input().split()))
p = list(map(int,input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
n,k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ansp = p[0:k]
print(sum(ansp))

Solution (Python):
N,K=map(int,input().split())
p_N = [int(i) for i in input().split()]
import heapq
print(sum(heapq.nsmallest(K,p_N)))

Solution (Python):
N, K = map(int, input().split())
price = list(map(int, input().split()))

price.sort()
sum = 0
for i in range(K):
    sum += price[i]

print(sum)

Solution (Python):
N=list(map(int,input().split()))
S=list(map(int,input().split()))
S.sort()
x=0
for i in range(N[1]):
  x=x+S[i]
print(x)

Solution (Python):
N, M = map(int, input().split())
p = list(map(int, input().split()))
a = sorted(p, reverse=False)
c = 0
for b in a[:M]:
  c = c + b
print(c)

Solution (Python):
n, k = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
print(sum(lst[:k]))

Solution (Python):
N, K = map(int, input().split())
p = tuple(map(int, input().split()))
print(sum(sorted(p)[:K]))

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

Solution (Python):
N,k=map(int,input().split())
hako=list(map(int,input().split()))
hako.sort(reverse=True)
fin=0
for i in range(k):
  fin=fin+hako.pop()
print(fin)

Solution (Python):
import numpy

N, K = (int(x) for x in input().split())

p = [int(x) for x in input().split()]

p.sort()

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

print(ans)

Solution (Python):
NK = input().split()
n = int(NK[0])
k = int(NK[1])
arr = list(map(int, input().split()))
arr.sort()
print(sum(arr[0:k]))

Solution (Python):
N,K= map(int,input().split())
P = list(map(int,input().split()))
Pnew = sorted(P)
total = 0
for i in range(K):
    total += Pnew[i]

print(str(total))

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
for i in range(K):
  ans+=int(p[i])
print(ans)

Solution (Python):
n, k = map(int,input().split())
nums = sorted(map(int, input().split()))  
print(sum(nums[:k]))

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
total = 0
for i in range(k):
  total += p[i]
print(total)

Solution (Python):
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
a = [0]*k
for i in range(k):
  a[i] = min(p) + a[i-1]
  b = p.index(min(p))
  p[b] = 1001
print(a[k-1])

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
N, K = map(int, input().split())

p = sorted(list(map(int, input().split())))

a = p[:K]

print(sum(a))

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

p.sort()

print(sum(p[:k]))

Solution (Python):
n,k=map(int, input().split())
l = [int(x) for x in input().split()]
ans=0
l.sort()
for i in range(k):
    ans += l[i]

print(ans)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
print(sum(sorted(p)[:K]))

Solution (Python):
n, k = map(int, input().split())
prices = list(map(int, input().split()))
prices.sort()
print(sum(prices[:k]))

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
SUM=0
for i in range(K):
    SUM+=p[i]

print(SUM)

Solution (Python):
N, K = map(int, input().split())
p_list=sorted(list(map(int, input().split())))

print(sum(p_list[:K]))

Solution (Python):
X,Y = map(int,input().split())
MMM = map (int,input().split())
MM = list(MMM)
MM.sort()
total = 0
for i in range(Y):
  total += MM[i]
print(total)

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

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

p.sort()

print(sum(p[:k]))

Solution (Python):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

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

p.sort()
ans = sum(p[0:k])
print(ans)

Solution (Python):
NK = list(map(int,input().split()))
prices = list(map(int,input().split()))

prices.sort()
print(sum(prices[:NK[1]]))

Solution (Python):
N,K=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=0
for i in range(K):
    b+=a[i]
print(b)

Solution (Python):
N,K = (int(x) for x in input().split())
A=list(map(int,input().split()))
A.sort()
sum=0
for i in range(K):
    sum+=A[i]
print(sum)

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

Solution (Python):

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

Solution (Python):
N,K = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
money = 0
for j in range(K):
    money += p[j]
print(money)

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

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

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
sum = 0
P.sort()

for i in range(NK[1]):
  sum+=P[i]

print(sum)

Solution (Python):
n, k = map(int, input().split())

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

P = sorted(p)
price = 0
for i in range(k):
    price += P[i]

print(price)

Solution (Python):

N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
n,k = map(int, input().split())
s = list(map(int,input().strip().split()))

t = 0
ss = sorted(s)
for kk in range(k):
    t += ss[kk]
print(t)

Solution (Python):
N, K = input().split(sep=' ')
p = list(input().split(sep=' '))
p = list(map(int, p))
p.sort()
buy = 0
for item in range(int(K)):
  buy += p[item]
print(buy)

Solution (Python):
n,m=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
for i in range(m):
  ans+=p[i]
print(ans)

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

Solution (Python):
def Qb():
    n, k = map(int, input().split())
    f = list(map(int, input().split()))
    f.sort()
    print(sum(f[:k]))

if __name__ == '__main__':
    Qb()

Solution (Python):
n, k = map(int, input().split())
p_lst = list(map(int, input().split()))

p_lst = sorted(p_lst)
print(sum(p_lst[:k]))

Solution (Python):
N, K = [int(i) for i in input().split(' ')]
p = [int(i) for i in input().split(' ')]
print(sum(sorted(p)[:K]))

Solution (Python):
N, K = list(map(int, input().split()))
p = sorted(list(map(int, input().split())), reverse=False)

print(sum(p[:K]))

Solution (Python):
N = list(map(int, input().split()))
fruits = list(map(int, input().split()))
sum = 0
fruits.sort()

for i in range(N[1]):
    sum +=  fruits[i]
print(sum)

Solution (Python):
nk = [int(s) for s in input().split()]
k = nk[1]

p = [int(s) for s in input().split()]

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

Solution (Python):
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))

print(sum(p[:k]))

Solution (Python):
n, k= map(int, input().split())
p = list(map(int, input().split()))
p.sort()
S = 0
for i in range(k):
  S = S + p[i]
print(S)

Solution (Python):
n, k = map(int, input().split())
p = [int(s) for s in input().split()]
sum = 0

for i in range(k):
    sum += min(p)
    p.remove(min(p))
print(sum)

Solution (Python):
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]










n,k = MI()
li = sorted(LI())
print(sum(li[:k]))

Solution (Python):

def main():
    
    kinds = list(map(int,input().split()))
    prices = list(map(int,input().split()))
    
    minPrice = 0
    
    for item in range(kinds[1]):
        minPrice += min(prices)
        prices.remove(min(prices))

    print(minPrice)         
    
  

if __name__ == "__main__":
    main()

Solution (Python):
import math
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

def quickSort(arr):
  if len(set(arr)) == 1:
    return arr
  res = []
  pivot = arr[math.floor(len(arr)/2)]
  left = []
  right = []
  center = []
  for i in arr:
    if i < pivot:
      left.append(i)
    elif i > pivot:
      right.append(i)
    else:
      center.append(i)
  if len(left) != 0:
    res = quickSort(left)
  res.extend(center)
  if len(right) != 0:
    res.extend(quickSort(right))
  return res

p = quickSort(p)
print(sum(p[:K]))

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
p=sorted(p)
print(sum(p[0:K]))

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

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

print(ans)

Solution (Python):
n, k = 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)

Solution (Python):
n, k = map(int,input().split())
li = list(map(int, input().split()))[:n]
count = 0
li.sort()
for i in range(k):
    count+=li[i]

print(count)

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

p.sort()

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

print(ans)

Solution (Python):
N, K = map(int, input().split())
a = list(map(int, input().split()))

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

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

Solution (Python):
N, K = map(int, input().split()) 
A = sorted(map(int, input().split()))
ans = 0

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

print(ans)

Solution (Python):
n,k=input().split();print(sum(sorted(list(map(int,input().split())))[:int(k)]))

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

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
p = sorted(p)
ans = 0
for i in range(K):
  ans = ans + p[i] 
print(str(ans))

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

p = sorted(p)

p = p[:K]

print(sum(p))

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

p = sorted(p)  
sum = 0

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

Solution (Python):
M,N = map(int,input().split(" "))
A = list(map(int,input().rstrip().split(" ")))
a=sorted(A)
ans=0
for i in range(N):
    ans+=a[i]
print(ans)

Solution (Python):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
print(sum(l[:k]))

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[0:k]))

Solution (Python):

def input2():
	return map(int,input().split())


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

n,k=input2()
p=input_array()
sp=sorted(p)

print(sum(sp[:k]))

Solution (Python):
tmp = input().split(" ")
N = int(tmp[0])
K = int(tmp[1])
ary = list(map(lambda x: int(x), input().split(" ")))
ary.sort()

print(sum(ary[0:K]))

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

p_sort = sorted(p)

p_sum = sum(p_sort[0:k])

print(p_sum)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
_sum=0
for i in range(k):
    _sum += p[i]
print(_sum)

Solution (Python):
N,K=map(int,input().split())
p=list(map(int,input().split()))
print(sum(sorted(p)[:K]))

Solution (Python):
n,k=map(int,input().split())
p=sorted(map(int,input().split()))
ans=0
for i in range(k):
    ans+=p[i]
print(ans)

Solution (Python):
N, K = map(int, input().split())
p = [int(e) for e in input().split()]


p.sort()


ans = 0
for e in p[:K]:
  ans += e

print(ans)

Solution (Python):
n, k = map(int, input().split(" "))
p = map(int, input().split(" "))
print(sum(sorted(p)[:k]))

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
print(sum(a[:k]))

Solution (Python):
N,K = map(int,input().split())
p = list(map(int,input().split()))
print(sum(sorted(p)[:K]))

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
         
p.sort()
ans = sum(p[:k])
print(ans)

Solution (Python):

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

a = input().split()

a = list(map(int,a))

a.sort()

b = sum(a[:K])
print(b)

Solution (Python):
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)

Solution (Python):
N, K = map(int, input().split())
P = sorted(list(map(int, input().split())))
print(sum(P[:K]))

Solution (Python):
N, K = map(int,input().split())
P = list(map(int, input().split()))
P.sort()
print(sum(P[0:K]))

Solution (Python):
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return 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]))

Solution (Python):
def main():
    N, K = map(int, input().split())
    *P, = map(int, input().split())

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


if __name__ == '__main__':
    main()

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

P.sort()
s = 0
for i in range(K):
	s += P[i]

print(s)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=0
s=sorted(s)
for i in range(b):
  ans+=s[i]
print(ans)

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

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

Solution (Python):
n,k = map(int, input().split())
P = list(map(int, input().split()))

P.sort()

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

print(ans)

Solution (Python):


N, K = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
a = 0
for i in range(K):
    a += p[i]
print(a)

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

new_p = sorted(p)
sum = 0
for i in range(K):
	sum += new_p[i]
print(sum)

Solution (Python):
N, K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:K]))

Solution (Python):
N, K = map(int, input().split(' '))
ls = list(map(int, input().split(' ')))
ls.sort()
print(sum(ls[:K]))

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

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

Solution (Python):
N, K = map(int, input().split())
p = input("").split()
p = [int(i) for i in p]
p = sorted(p)

M = sum(p[0:K])
print(M)

Solution (Python):
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))

Solution (Python):
N,K = list(map(int,input().split()))

P = [int(x) for x in input().split()]

P.sort()

print(sum(P[:K]))

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

Solution (Python):
def main(istr, ostr):
    n, k = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    ls.sort()
    result = sum(ls[:k])
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
ans = 0
for i in range(K):
  ans += P[i]
print(ans)

Solution (Python):
num = input().split(" ")
num_all = int(num[0])
count = int(num[1])
cost = list(map(int, input().split()))
cost.sort()
last = 0
for i in range(count):
  last += cost[i]
print(last)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N,K = LI()
p = LI()
p.sort()
p1 = np.array(p)
print(p1[:K].sum())

Solution (Python):
N,K=list(map(int,input().split()))
A = [int(x) for x in input().split()]
A.sort()
print(sum(A[:K]))

Solution (Python):


a, b = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
o = 0
for i in range(b):
    o = o+x[i]
print(o)

Solution (Python):

n, k = map(int,input().split())
p = [int(i) for i in input().split()]

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

Solution (Python):
N,K=map(int,input().split())
p=[int(i) for i in input().split()]

sort=sorted(p)
ans=0
for i,j in enumerate(sort):
    if i==K:
        break
    ans+=j
print(ans)

Solution (Python):
N,K=input().split()
N=int(N)
K=int(K)

p = [int(i) for i in input().split()]
p.sort()
print(sum(p[0:K]))

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

p.sort()

ans = 0

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

print(ans)

Solution (Python):
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
s=0
for i in range(K):
    s+=A[i]
print(s)

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
N, K=list(map(int, input().split()))
P=list(map(int, input().split()))
ans=0
P.sort()

for i in range(K):
    ans = ans + P[i]
print(ans)

Solution (Python):
N, K = map(int,input().split())
p = sorted(list(map(int,input().split())))

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

print(ans)

Solution (Python):
n, k = 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)

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

Solution (Python):
def solve(string):
    n, k, *p = map(int, string.split())
    p = sorted(p)
    return str(sum(p[:k]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
n,k=map(int,input().split())
ar=list(map(int,input().split()))
ar.sort()
pos=0
for i in range(k):
  pos+=ar[i]
print(pos)

Solution (Python):
N, K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()

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

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

Solution (Python):
n, k = map(int, input().split())
lst = [int(i) for i in input().split()]

count = 0
min_price = 0
while count < k:
  
  total = min_price
  for i in range(len(lst)):
    total += lst[i]
    
    if i == 0:
      min_price = total
      min_index = i
    elif total < min_price:
      min_price = total
      min_index = i
    total -= lst[i]
  lst.pop(min_index)
  count += 1
print(min_price)

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

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))

Solution (Python):
n,k = map(int,input().split())
p = map(int,input().split())
p = sorted(p)
total = 0
for i in range(k):
  total += p[i]
print(total)

Solution (Python):
import numpy as np

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

p = np.array(p)
p = np.sort(p)

ans = p[:K].sum()

print(ans)

Solution (Python):
N, K = map(int, input().split())
p = sorted(list(map(int, input().split())))

print(sum(p[0:K]))

Solution (Python):
a=input()
l=a.split(" ")
n=int(l[0])
k=int(l[1])
f=input()
fruits=f.split(" ")
for d in range(0, len(fruits)):
    fruits[d]=int(fruits[d])
ans=0
b=0
while(b<k):
    g=min(fruits)
    ans+=g
    fruits.remove(g)
    b+=1
print(ans)

Solution (Python):
N, K = map(int, input().split())

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

p.sort()
cost = 0

for k in range(K):
    cost += p[k]
print(cost)

Solution (Python):
N, K = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
ans = sum(arr[:K])
print(ans)

Solution (Python):
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(list(dict.fromkeys(ans)))
    if(ans[-1]==n):
        ans = ans[:-1]
    return ans

n,k = map(int, input().split())
nums = sorted(list(map(int, input().split())))
ans = sum(nums[:k])
print(ans)

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

p.sort()

sum = 0

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

print(sum)

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

print(sum(a[:k]))

Solution (Python):
N, K = map(int, input().split())
p = list(map(int, input().split()))
sum_price = 0
p.sort()
print(sum(p[0:K]))

Solution (Python):


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

p_list = sorted(p_list)

total_val = 0

for i in range(K):
    total_val += p_list[i]

print(total_val)

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

p.sort()

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

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

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

Solution (Python):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
print(sum(p[0:k]))

Solution (Python):
n,k = map(int, input().split())
lst_p=list()
tot=0

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

def sort(my_list):
    size = len(my_list)
    for i in range(size):
        for j in range(size-i-1):
            if(my_list[j] > my_list[j+1]):
                tmp = my_list[j]
                my_list[j] = my_list[j+1]
                my_list[j+1] = tmp
    return my_list

lst_p = sort(lst_p)

for i in range(k):
    tot += lst_p[i]
print(tot)

Solution (Python):
asdfasdfasdf, a = map(int, input().split())
b = list(map(int, input().split()))
d = 0
for c in range(a):
    d += min(b)
    b.remove(min(b))
print(d)

Solution (Python):

def inputlist(): return [int(j) for j in input().split()]

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

Solution (Python):
N,K=map(int,input().split())
x=list(map(int,input().split()))
x.sort()

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

print(ans)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
total = 0
for i in range(k):
    total+=p[i]
print(total)

Solution (Python):
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
total = 0
for i in range(k):
    total+=p[i]
print(total)

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

p.sort()

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

print(ans)

Solution (Python):
n,k=map(int,input().split())
p_list=list(map(int,input().split()))
p_list=sorted(p_list)
new_p_list=[]
for i in range(k):
    new_p_list.append(p_list[i])
print(sum(new_p_list))

Solution (Python):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

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

Solution (Python):
N, K = map(int, input().split())

p = list(map(int, input().split()))
p.sort()
sum = 0
for i in range(K):
    sum += p[i]
print(sum)

Solution (Python):
n,k=(int(i) for i in input().split())

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

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

print(sum(p[:k]))

Solution (Python):
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
n,k = inm()
p = inl()
p = sorted(p)
print(sum(p[:k]))

Solution (Python):
N,K = map(int,input().split())
L = list(map(int,input().split()))

L.sort()

print(sum(L[:K]))

Solution (Python):
[n,k] = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p.sort()
total = 0
for i in range(k):
  	total += p[i]
print(total)

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

p_new = sorted(p)
sum = 0
for i in range(k):
    sum += p_new[i]
    
print(sum)

Solution (Python):
n,k=map(int,input().split())
price=list(map(int,input().split()))

s_price=sorted(price)

mysum=0

for i in range(k):
  mysum+=s_price[i]
  
print(mysum)

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

p = sorted(p)
ans = sum(p[:k])
print(ans)

Solution (Python):
n, k = map(int,input().split())
l = list(map(int,input().split()))

l_min = sorted(l)

print(sum(l_min[0:k]))

Solution (Python):
def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

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

if __name__ == "__main__":
    resolve()