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

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

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

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()
result=0
for i in range(K):
    result+=p[i]

print(result)

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):
A = list(map(int , input().split()))
B = list(map(int , input().split()))
print(sum(sorted(B)[:A[1]]))

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

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

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

print(q)

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

Solution (Python):

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

Solution (Python):
if __name__ == '__main__':

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

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

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

Solution (Python):
_,k,*p=map(int,open(0).read().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[: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())
p = list(map(int,input().split()))
p.sort()
res = 0
for i in range(k):
  res += p[i]
print(res)

Solution (Python):
def mix_juice():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()
    res = 0
    for i in range(K):
        res += p.pop(0)
    print(res)
    
mix_juice()

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

A.sort()
min = 0

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

Solution (Python):


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

ans = sum(sorted(p_list)[:K])

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 = sorted(list(map(int, input().split())))
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()))
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())
money = [int(x) for x in input().split()]
ans = 0

money.sort()

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

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

P = sorted(P)

print(sum(P[:K]))

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

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

if '__main__' == __name__:
    resolve()

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())
price = list(map(int, input().split()))
price.sort()
print(sum(price[:K]))

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n, k = map(int,input().split())
    P = sorted(list(map(int,input().split())))
    print(sum(P[:k]))


if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n, k = map(int,input().split())
    P = sorted(list(map(int,input().split())))
    print(sum(P[:k]))


if __name__=='__main__':
    main()

Solution (Python):
n,k = list(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()
print(sum(p[0:k]))

Solution (Python):
NK = [int(i) for i in input().split(' ')]
p=[int(i) for i in input().split(' ')]
p.sort()
S=sum(p[0:NK[1]])
print(S)

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

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

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

arr.sort()

ans = 0

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

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

print(sum(prices[:k]))

Solution (Python):

def main():
    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)


if __name__ == "__main__":
    main()

Solution (Python):
l = input().split()
n1 = int(l[0])
n2 = int(l[1])

money = input().split()

for i in range(n1):
    money[i] = int(money[i])

money.sort()

ans = 0

for i in range(n2):
    ans += money[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())
fruits = list(map(int,input().split()))
fruits.sort()
ans = 0
for i in range(k):
    ans += fruits[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()

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

print(sum(sorted(P)[: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.sort()
ans=0

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

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

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

print(sum)

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

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

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

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

P.sort()
result = 0
i = 0
for n in P :
    if i == K:
        break
    result+=n
    i+=1
print(result)

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

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

Solution (Python):
N,K = map(int, input().split())
P=list(map(int, input().split()))
print(sum(sorted(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=list(map(int, input().split(" ")))

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

sum=0
for i in range(K):
  sum=sum+sorted(P)[i]

print(sum)

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

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

print(ans)

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

print(sum(l[:k]))

Solution (Python):
N,K = map(int,input().split())
array = sorted(list(map(int,input().split())))
ans = sum(array[0: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())

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

l = sorted(l)
print(sum(l[0:k]))

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

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

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

sx=sorted(x)
ans=0
for i in range(k):
  ans=ans + sx[i] 
print(ans)

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

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

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

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

p=list(p)
p.sort()

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

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

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()))
l = sorted(p)

s = sum(l[:k])
print(s)

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

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

p_list.sort()

ans = 0

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

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

for i in range(N):
    for n in range(N-1):
        if p[n]>p[n+1]:
            tmp = p[n]
            p[n] = p[n+1]
            p[n+1] = tmp

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

print(ans)

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

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

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

Solution (Python):
import numpy as np

N, K = map(int, input().split())
A = [int(i) for i in input().rstrip().split()]
A.sort()

B = A[0:K]
ans = np.sum(B)
print(ans)

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

    p_lst.sort()

    print(sum(p_lst[:k]))


if __name__ == "__main__":
    main()

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

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()))
Psort = sorted(P)
sum = 0

for i in range(K):
  sum = sum + Psort[i]

print(sum)

Solution (Python):
def sol():
    n, k = map(int, input().split())
    ps = list(map(int, input().split()))
    sort_ps = sorted(ps)
    ans = 0
    for i in range(k):
        ans += sort_ps[i]
    print(ans)
if __name__ == "__main__":
    sol()

Solution (Python):
n,k,*p=map(int,open(0).read().split());print(sum(sorted(p)[:k]))

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

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

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

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

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

Solution (Python):
N, K = input().split()
IK = int(K)
P = list(map(int, input().split()))
Sorted_P = sorted(P)
S = 0
i = 0

while i < IK:
    S = S + Sorted_P[i]
    i = i + 1


print(S)

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

a = sorted(P)

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

print(ans)

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

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

print(result)

Solution (Python):
n, k = (int(x) for x in input().split())
list_p = sorted([int(y) for y in input().split()])
price = 0

for i in range(0, k):
    price += list_p[i]

print(price)

Solution (Python):
n, k = [int(n) for n in input().split(' ')]
p = [int(n) for n 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):
N,K=map(int,input().split())
p=sorted(list(map(int,input().split())))
all=0
for i in range(K):
    all+=p[i]
print(all)

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

Solution (Python):
N, K = (int(x) for x in input().split())
p = list(map(int, input().split()))
p_sort = sorted(p)
print(sum(p_sort[0: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 = sum + p[i]
print(sum)

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

print(sum(clist[:k]))

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

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

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

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

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

P=sorted(p)

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

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

Solution (Python):
n,k=[int(i) for i in input().strip().split(" ")]
arr=[int(i) for i in input().strip().split(" ")] 
ans=0
arr=sorted(arr)
for i in range(k):
    ans+=arr[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()
count = 0

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

Solution (Python):

import sys
from itertools import chain






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 = int(next(tokens))  
    K = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    answer = solve(N, K, p)
    print(answer)


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

p.sort()

s = sum(p[:k])

print(s)

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

min_price = 0
for i in range(k) : 
    min_price += price[i]
    
print(min_price)

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 = list(map(int, input().rstrip().split()))
l = sorted(list(map(int, input().rstrip().split())))
r = sum(l[0:K])
print(r)

Solution (Python):
_,k,*p=map(int,open(0).read().split())
p.sort()
print(sum(p[:k]))

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

Solution (Python):
[N, K] = list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort(reverse=True)

total = 0
for i in range(K):
    total += P.pop()

print (total)

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 = sorted(list(map(int,input().split())))
print(sum(P[: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()
print(sum(p[:K]))

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

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
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 = MI()
p = LI()
p.sort()
print(sum(p[i] for i in range(K)))

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

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

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

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

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())
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())))
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()
c = 0

for i in range(K):
  c = c + a[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())
P = list(int(n) for n in input().strip().split())[:N]
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()
print(sum(p[:k]))

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

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

print(ans)

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

prices.sort()

print(sum(prices[:K]))

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

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

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

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

print(pay)

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()
b=0

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

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

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

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

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

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

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

Solution (Python):
k = int(input().split(' ')[1])

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

s = sum(n[0:k])

print(s)

Solution (Python):



def next_line():
    return input()


def next_int():
    return int(input())


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


def strs():
    return input().split()


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


def int_ar_mul(size):
    return [int(input()) for _ in range(size)]


def str_ar(size):
    return [input() for _ in range(size)]


def main():
    n, k = ints()
    p = sorted(int_ar())
    res = 0
    for i in range(k):
        res += p[i]
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
r=input().split()
N=int(r[0])
K=int(r[1])
d_pre=input().split()
d=[int(s) for s in d_pre]
d.sort()
ans=0
for i in range(K):
    ans+=d[i]
print(ans)

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

p_sort = p.sort()
p_sort_K = p[0:K]
print(sum(p_sort_K))

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

for i in range(k):
    price += c[i]
print(price)

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

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

sum = 0

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

Solution (Python):

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

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

p=list(map(int,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()


sum = 0
for i in range(K):
	sum = 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 = list(map(int, input().split()))
ans = 0

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, k = inm()
a = sorted(inl())
print(sum(a[:k]))

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

price = []
for i in range(0, k):
    price.append(sortPrice[i])
print(sum(price))

Solution (Python):
a, nums = map(int, input().split())
add = 0
lst = list(map(int, input().split()))
lst.sort()
for i in range(0,nums):
  add += lst[i]

print(add)

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

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

ans = 0
for i in range(K):
    ans += min(lst)
    lst.remove(min(lst))
    
print(ans)

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

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

if __name__ == "__main__":
    solve()

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

print(sum(sorted(P)[:K]))

Solution (Python):
N, K = (int(a) for a in input().split())
p = [int(a) for a 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()
print(sum(P[:K]))

Solution (Python):
k = int(input().split(' ')[1])

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

s = sum(n[0:k])

print(s)

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

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

Solution (Python):

import sys
input = sys.stdin.readline

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


n, k = inlt()
p = inlt()
p = sorted(p)
print(sum(p[:k]))

Solution (Python):
n,k = input().split()
k = int(k)-1
a = list()
a = input().split(" ")
b = list()
for i in a:
    b.append(int(i))
b.sort()
sum = 0
while k>=0:
    sum += b[k]
    k -= 1
print(sum)

Solution (Python):



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

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

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

Solution (Python):
a,b = input().split(" ")
lst = list(map(int,input().split(" ")))
lst_s = sorted(lst)
res = lst_s[0:int(b)]
print(sum(res))

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

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

if __name__ == '__main__':
    main()

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

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