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()))
price = 0
new_p = sorted(p)
for i in range(k):
	price = price + new_p[i]
print(price)

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

Solution (Python):
N,K = map(int,input().split())
A = sorted(map(int,input().split()))
print(sum(A[: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):
hepsi,secili=list(map(int,input().split()))
arr=list(map(int,input().split()))
arr.sort()
sum=0
for i in range(secili):
	sum+=arr[i]
print(sum)

Solution (Python):
i = list(map(int,input().split()))
p = list(map(int,input().split()))
N = i[0]
K = i[1]

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

print(t)

Solution (Python):
N,K = input().split(" ")
prices = [int(s) for s in input().split(" ")]
prices.sort()
print(sum(prices[0:int(K)]))

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

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

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

Solution (Python):
INT_MAX=10**30+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[-1 for _ in range(n)]for _ in range(m)]

n,k=INPUT()
A=INPUT()
A.sort()
print(sum(A[0:k]))

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

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

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

print(ans)

Solution (Python):
i = list(map(int, input().split()))
i2 = list(map(int, input().split()))

n = i[0]
k = i[1]

i2.sort()

ans = 0
for x in i2[0:k]:
    ans = ans + x
print(ans)

Solution (Python):
import sys
L = []
for l in sys.stdin:
    L.append(l)
N, K = map(int, L[0].split())
p_N_list = list(map(int, L[1].split()))
p_N_list.sort()
sum = 0
for n in range(0, K):
  sum += p_N_list[n]
print(sum)

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

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

print(sum(p[:k]))

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

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

Solution (Python):
FruitVal,Fruit = map(int,input().split())
FList = list(map(int,input().split()))

addNum = 0

FList.sort()

for i in range(Fruit):
    addNum += FList[i]

print(addNum)

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

Solution (Python):
n,k = map(int,input().split())
p = list(map(int, input().split()))
ans = 0
i = 0
while i<k:
    ans += min(p)
    p.remove(min(p))
    i+=1
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())
p = list(map(int,input().split()))
p.sort()
ls = []
for i in range(K):
    ls.append(p[i])
print(sum(ls))

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

ans=0
p.sort()
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 = list(map(int, input().split()))



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





a.sort()





result = 0

for i in range (K):
 result += a[i]

print (result)

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

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

Solution (Python):
N, K = map(int, input().split())
P = list(map(int,input().split()))
P.sort()
P_sum = 0
for i in range(K):
    P_sum = P_sum + P[i]
print(P_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):
li = list(map(int, input().split()))
li2 = sorted(list(map(int, input().split())))
re = 0
for i in range(li[1]):
    re += li2[i]
print(re)

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())
lists = list(map(int,input().split()))
lists.sort()

print(sum(lists[:K]))

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

B = sorted(P)
count = 0
for x in range(K):
    count = count + B[x]

print(count)

Solution (Python):
n,k=map(int,input('').split(' '))
p=input('')
p=p.split(' ')
for a in range(n):
    p[a]=int(p[a])

l=[]
for a in range(1001):
    l.append(0)

for a in range(n):
    l[p[a]]+=1

h=0
q=0
c=0
s=0
while c==0:
    if l[h]>0:
        l[h]-=1
        q+=h
        s+=1
    else:
        h+=1
    
    if s==k:
        c=1
    else:
        c=0

print(q)

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

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

li = []
for i in range(n):
    li.append(p[i-1])
        
li_int = sorted([int(n) for n in li])

li_ans = li_int[:k]

print(sum(li_ans))

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

Ans = sorted(P)[0:K:]
print(sum(Ans))

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):
N,K=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
res=0
for x in p[:K]:
	res+=x

print(res)

Solution (Python):
n,k = map(int,input().split())
s = list(map(int,input().split()))
s = sorted(s,reverse = False)
s = s[0:k]
a = 0
for b in s:
    a = a + b
print(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 = input().split()
p = sorted(map(int, input().split()))
print(sum(p[0:int(K)]))

Solution (Python):
import functools
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
cost=functools.reduce(lambda x,y:x+y,p[:k],0)
print(cost)

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())
c = list(map(int, input().split()))
d = 0
c.sort()
for i in range(0,b):
  d = d + c[i]
print(d)

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

print(sum(p[:k]))

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

N = a[0]
K = a[1]

B = sorted(b)
C = B[:K]
print(sum(C))

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())
price = list(map(int,input().split()))
price.sort()
P = 0
for i in range(k):
    P+=price[i]
print(P)

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 = list(map(int, input().split()))
p.sort()
x = 0
for i in range(K):
    x += p[i]
print(x)

Solution (Python):
a = input().split()
n = int(a[0])
k = int(a[1])
p = [int(i) for i in input().split()]
p_sorted = sorted(p)
print(sum(p_sorted[0:k]))

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

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

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

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

Solution (Python):
I=lambda:list(map(int,input().split()))
n,k=I()
l=sorted(I())
print(sum(l[: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())
x = list(map(int, input().split()))
x_sorted = sorted(x)
f_x = x_sorted[:K]
print(sum(f_x))

Solution (Python):
n, k = [int(a) for a in input().split()]
ps = [int(a) for a in input().split()]

ps.sort()
print(sum(ps[0:k]))

Solution (Python):
n, k = map(int, input().split())
p = [int(e) for e 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())
a=list(map(int,input().split()))
ans=0
for i in range(k):
  ans+=min(a)
  a.remove(min(a))
print(ans)

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

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().split())
p = list(map(int, sys.stdin.readline().split()))
p.sort()
print(sum(p[0:K]))

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

Solution (Python):
N,K = [int(x) for x in input().split()]
price = [int(x) for x in input().split()]
sort_price = sorted(price)
print(sum(sort_price[:K]))

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

p = sorted(p)

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

Solution (Python):
def A(x):
  if ord(x) - ord('a') >= 0:
    print('a')
  else:
    print('A')


def B(n, k, p_list):
  p_list = sorted(p_list)
  print(sum(p_list[:k]))


def main():
  
  
  
  

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


if __name__ == '__main__':
  main()

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

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

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

q= sorted(p)

import numpy as np

r= np.cumsum(q)

print(r[k-1])

Solution (Python):
import numpy as np
N, K = list(map(int, input().split()))
p = np.array(list(map(int, input().split())))

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

Solution (Python):
a,b=map(int,input().split())
C=list(map(int,input().split())) 

D=sorted(C)
print(sum(D[:b]))

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

ps.sort()


ans = sum(ps[:K])

print(ans)

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

p.sort()

l = 0
price = 0
while(l<K):
    price += p[l]
    l += 1
    
print(price)

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

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

p.sort()

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

print(sum)

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

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):
x, k = map(int, input().split())
ps = list(map(int, input().split()))
ps = sorted(ps)
print(sum(i for i in ps[:k]))

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

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

Solution (Python):
I1 = input().split()
I2 = input().split()
I2X = []
for a in I2:
    I2X.append(int(a))

I2X.sort()

print(sum(I2X[:int(I1[1])]))

Solution (Python):
import numpy as np
n,k = [int(e) for e in input().split()]
nums = np.array([int(e) for e in input().split()])
nums.sort()
ans = sum(nums[:k])

print(ans)

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

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

yen = 0
if N >= K:
    for i in range(K):
        yen += p[i]

print(yen)

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

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

for j in range(K):
    ans = ans + p_sort[j]

print(ans)

Solution (Python):
N, K = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
p.sort()
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[0:K]))

Solution (Python):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
p=nl()
p.sort()
sum_m=0
for i in range(K):
    sum_m+=p[i]

print(sum_m)

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

print(sum)

Solution (Python):
def _main(N, K, prices):
    prices.sort()
    print(sum(prices[0:K]))


def _entry():
    N, K = map(int, input().split())
    pricecs = list(map(int, input().split()))
    _main(N, K, pricecs)


if __name__ == "__main__":
    _entry()

Solution (Python):
input1 = list(map(int, input().split()))
p = list(map(int, input().split()))
N = input1[0]
K = input1[1]

p.sort()

print(sum(p[:K]))

Solution (Python):







 




'''

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

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

'''
n,k = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
'''
 




p.sort()

P=[]
for i in range(k):
    P.append(p[i])
print(sum(P))

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):
import sys

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

  
  arr = list(map(int, input().split()))
  arr.sort()

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

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
all, kind = map(int, input().split())
price = list(map(int, input().split()))
price.sort()

print(sum(price[0:kind]))

Solution (Python):



nums = []
nums = input().split(" ")
num1 = int(nums[0])
num2 = int(nums[1])

money = []
money=input().split(" ")


money2 = []
for i in range(num1):
    money2.append(int(money[i]))

money2=sorted(money2)


    
total=0
for i in range(num2):
    total = (money2[i])+total
print(total)

Solution (Python):
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

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


if __name__ == '__main__':
    main()

Solution (Python):
import heapq

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

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

print(sum(heapq.nsmallest(k, p)))

Solution (Python):
import numpy as np

s = input().split(" ")
p = input().split(" ")
N = int(s[0])
K = int(s[1])
p = np.array([int(p[n]) for n in range(N)])
print(np.sum(np.sort(p)[0:K]))

Solution (Python):

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

l.sort()
a = 0
for i in range(0,k):
    a += l[i]

print(a)

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

res = 0
for i in range(k):
    res += a[i]
print(res)

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

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

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())
fruits_list = list(map(int, input().split()))

fruits_list_low = sorted(fruits_list)

cost = 0

for i in range(0, k):
    cost += fruits_list_low[i]
    
print(cost)

Solution (Python):
def MixJuice():

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

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

    value.sort()

    total = 0

    for i in range(Num[1]):
        total = total + value[i]

    print(total)

if __name__ == '__main__':
    MixJuice()

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()
r = 0
for i in range(k):
    r += p.pop(0)
print(r)

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

s = list(map(int, input().split()))
s.sort()

cost=0
for i in range(k):
    cost+=s[i]
    
print(cost)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline

n, k = list(map(int, readline().split()))
p = list(map(int, readline().split()))
p.sort()
a = sum(p[:k])

print(a)

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

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

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

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

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

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

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

p_n.sort(reverse =True)
ans = 0
for i in range(K):
    ans +=p_n.pop()
    
print(ans)

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

p_sort = sorted(p)
ans = 0

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

print(ans)

Solution (Python):
a,b = map(int,input().split())
listA = list(map(int,input().split()))
listA.sort()
all = 0

for i in range(b):
  all = all + listA[i]

print(all)

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

x = (sorted(p))
g = sum(x[:k])
print(g)

Solution (Python):

n,k = map(int, input().split())
p = list(map(int, input().split()))
ans=0
for i in range(k):
    an = min(p)
    ans=ans+an
    a = p.index(an)
    p.pop(a)

print(ans)

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

p_list.sort()

out = sum(p_list[0:k])
print(out)

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

a.sort()

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

print(ans)

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

Solution (Python):
n, k=input().split()
n, k=int(n), int(k)
val=input().split()
val=[int(i) for i in val]
val=sorted(val)
sum=0

for j in range(k):
    sum+=val[j]

print(sum)

Solution (Python):
n, k = [int(s) for s in input().split(" ")]
plist = [int(s) for s in input().split(" ")]

plist.sort()
ans = 0
for kk in range(k):
  ans += plist[kk]

print(ans)

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

p=list(map(int,input().split()))
co=0
p.sort()

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


print(co)

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

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

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

print(sum(p[:k]))

Solution (Python):
line = input().rstrip().split(' ')
n = int(line[0])
k = int(line[1])

line = input().rstrip().split(' ')
p = []

for i in range(n):
    p.append(int(line[i]))

p.sort()

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

print(ans)

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

ps.sort()
print(sum(ps[0:k]))

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

k = nk[1]
p.sort()
a = 0
for j in range(k):

  a += p[j]
print(a)

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

array=input().split(" ")
for i in range(int(N)):
  n=int(array[i])
  array[i]=n

array.sort()

for j in range(int(K)):
  sum=sum+array[j]
print(sum)

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

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

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

print(ans)

Solution (Python):
n, k = 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())
p = list(map(int, input().split()))
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()))

s = 0

p.sort()

for n in range(K):
    s += p[n]

print(s)

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

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, p: "List[int]"):
    p.sort()
    ret = sum(p[:K])
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(N, K, p)

if __name__ == '__main__':
    main()

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())
pn = [int(num) for num in input().split()]

pn.sort()

count = 0
for i in range(k):
  count+=pn[i]

print(count)

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

Solution (Python):
from sys import stdin




def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())

res=['Yes', 'No']



test_case=1
while test_case:
    test_case-=1


    n, k=mi()
    a=li()
    a.sort()
    print(sum(a[:k]))

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

ans = 0

p.sort()

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

print(ans)

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

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

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

Solution (Python):
import sys

if __name__ == '__main__':
    n, k = list(map(lambda x: int(x), sys.stdin.readline().split()))
    p = list(map(lambda x: int(x), sys.stdin.readline().split()))
    p = sorted(p)
    print(sum(p[:k]))

Solution (Python):


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict

n,k = map(int, input().split())
p = list(map(int, input().split()))
ans=0
for i in range(k):
    an = min(p)
    ans=ans+an
    a = p.index(an)
    p.pop(a)

print(ans)

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

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

P = sorted(P)

ans = sum(P[0:K])

print(ans)

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

p.sort()

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

Solution (Python):

if __name__ == "__main__":
  N, K = [int(a) for a in input().split()]
  P = list(map(int, input().split()))
  list.sort(P)
  ans = sum(P[:K])
  print(ans)

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

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):

N, K = list(map(int, input().split()))
P = sorted(map(int, input().split()))
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()))
P=sorted(P)
ans=0
for i in range(K):
    ans+=P[i]
print(ans)

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

li=sorted(li)

total=[]
for i in range(1,k+1):
  total.append(li[i-1])
print(sum(total))

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

p.sort(reverse=False)
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()))

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

print(money)

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

p = sorted(p)
for i in range(int(k)):
    total.append(p[i])
print(sum(total))

Solution (Python):
a,b = map(int,input().split())
c = list(map(int,input().split()))
c.sort()
print(sum(c[0:b]))

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()
set(p)
print(sum(p[:K]))

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

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

plist =    [int(n) for n in input().split()]

import numpy as np

parray = np.array(plist)

sortp = np.sort(parray)

result = sortp[:K]

print(result.sum())

Solution (Python):
N,K = [int(a) for a in input().split()]
P = [int(a) for a in input().split()]
for i in range(len(P)-1):
    for j in reversed(range(i, len(P)-1)):
        if P[j] > P[j+1]:
            P[j], P[j+1] = P[j+1], P[j]
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):
n,k = map(int,input().split())
p = list(map(int,input().split()))
v = sorted(p)
a = v[0:k]
print(sum(a))

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

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

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

prices.sort()
result = 0

for i in range(K):
    result += prices[i]

print(result)

Solution (Python):
n,k=map(int,input().split())
li=list(map(int,input().split()))
sum=0
for i in range(k):
  sum=sum+min(li)
  li.remove(min(li))
print(sum)

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

L_2=sorted(L)

L_3=L_2[0:k]
print(sum(L_3))

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

get = []
for i in range(K):
    get.append(L[i])

print(sum(get))

Solution (Python):
a,b=input().split()
a=int(a)
b=int(b)
s=list(input().split())
r = [int(n) for n in s]
new=sorted(r)
output=sum(new[0:b])
print(output)

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