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 = list(map(int, input().split(" ")))
price = list(map(int, input().split(" ")))
minimum = 0
for i in range(n):
    swap = False
    for j in range(0, n-i-1):
        if price[j]>price[j+1]:
            price[j], price[j+1] = price[j+1], price[j]
            swap = True
    if swap == False:
        break
        
for i in range(k):
    minimum += price[i]
print(minimum)

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

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

Solution (Python):
no, sct = map(int, input().split(' '))
flut = list(map(int, input().split(' ')))
flut = sorted(flut, reverse=False)
sum_ = 0
for i in range(sct):
  sum_ += flut[i]
print(sum_)

Solution (Python):
N,K = map(int,input().split())
fruitPrice = list(map(int,input().split()))
fruitPrice.sort()
reversed(fruitPrice)
minimum = fruitPrice[0:K]

print(sum(minimum))

Solution (Python):
def sol():
    n,k=map(int,input().split())
    A=[int(i) for i in input().split()]
    A.sort()
    s=0
    for i in range(k):s+=A[i]
    print(s)
if(__name__=='__main__'):
    sol()

Solution (Python):
import copy as cp
N,K = input().split()
P = input().split()

PP = [int(n) for n in P]

print(sum(sorted(PP)[0:int(K)]))

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

bag = []
bag_max = 0

for i in range(n):

    if i < k:
        bag.append(p[i])
        if bag_max < p[i]:
            bag_max = p[i]
    else:
        if bag_max > p[i]:
            bag.append(p[i])
            bag.remove(bag_max)
            bag_max = max(bag)

print(sum(bag))

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

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

sortp = sorted(p)

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

Solution (Python):
import numpy as np
n, k = list(map(int, input().rstrip().split()))
p = list(map(int, input().rstrip().split()))
p = np.sort(np.array(p))
 
print(np.sum(p[:k]))

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

newP = P.sort()
sum_yen = 0

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

print(sum_yen)

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

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

Solution (Python):
import heapq

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

    array = (heapq.nsmallest(K, P))
    print(sum(array))

main()

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

num_list.sort()
min_list = num_list[:k]
min = sum(min_list)
print(min)

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
li = rl()
li.sort()
li = li[:k]
print(sum(li))

Solution (Python):
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
D = sorted(d)


print(sum(D[0:c]))

Solution (Python):
n, k = input().split()
n = int(n)
k = int(k)
listnum = input().split()
newlist = []
sumnum = 0

listnum = [int(n) for n in listnum]
newlist = sorted(listnum)
for b in range(k):
    sumnum = sumnum + newlist[b]
print(sumnum)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()


N, K = inm()
P = inl()
P.sort()


def solve():

    return sum(P[:K])


print(solve())

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

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

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

A_sorted = sorted(A)

minSum = 0

for i in range(K):
    minSum += A_sorted[i]

print(minSum)

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

Solution (Python):
N, K = [int(s) for s in input().split()]
print(sum(sorted([int(s) for s in input().split()])[: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 = (int(x) for x in input().split())
P = list(map(int, input().split()))
import heapq
Y = (heapq.nsmallest(K, P))
print(sum(Y))

Solution (Python):
N, K = map(int, input().split())
p = [int(s) for s in input().split()]
price = sorted(p)
total = 0

for i in range(K):
  total += price[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):
from sys import stdin

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

prices = sorted(prices)

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

ans = 0

B=sorted(A)

for a in B[:K]:
  ans += a
  if ans > 10**18:
    print('-1')
    break
else:
  print(ans)

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

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

print(ans)

Solution (Python):
from functools import reduce

N, K = [int(x) for x in input().split()]
P = sorted([int(x) for x in input().split()])
print(reduce(lambda x, y: x + y, P[0:K]))

Solution (Python):
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
l=list(mi())
l=sorted(l)
c=0
for i in range(b):
  c+=l[i]
print(c)

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

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

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

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

Solution (Python):
N,K=map(int,input().split())
a=input().split()
a1=[]
for i in range(len(a)):
  a1.append(int(a[i]))
S=0
for i in range(K):
  S+=min(a1)
  a1.remove(min(a1))
print(S)

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

Solution (Python):
import heapq

n,k = map(int,input().split())
l1 = list(map(int,input().split()))
l2 = heapq.nsmallest(k, l1)
print(int(sum(l2)))

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
count = 0
new_list = []
while count < K:
    min = P[0]
    for i in P:
        if min > i:
            min = i
    new_list.append(min)
    P.remove(min)
    count += 1
print(sum(new_list))

Solution (Python):
n,k=map(int,input().split())
a=[]
c=0

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

for j in range(0,k):
    c=c+a[j]
print(c)

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

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, *p = map(int, open(0).read().split())

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

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

Solution (Python):
t, select = input().split()
prices = input().split()

price_list = []
for price in prices:
    price_list.append(int(price))
    
price_list.sort()
total = 0
for i in range(int(select)):
    total += price_list[i]
print(total)

Solution (Python):
a=[input() for i in range(2)]

a1=a[0]
p=a[1]

a1=[int(i) for i in a1.split()]
p=[int(i) for i in p.split()]

p_up=sorted(p)

sum=0

for i in range(a1[1]):
	sum+=p_up[i]

print(sum)

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

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

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

s = sorted(p)

ans = 0 
for i in range(N):
    ans += s[i]
    if i == K-1:
        break

print(ans)

Solution (Python):
def main():
    N, K = input().split(' ')
    l = list(map(int, input().split(' ')))
    l.sort()
    sum = 0

    for i in range(int(K)):
        sum = sum + l[i]
    print(sum)

main()

Solution (Python):

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

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

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

price = 0
if N > 0:
    for j in range(K):
        price += p[j]
print(price)

Solution (Python):
from functools import reduce

N, K = [int(x) for x in input().split()]
P = sorted([int(x) for x in input().split()])
print(reduce(lambda x, y: x + y, P[0:K]))

Solution (Python):
n,k = map(int,input().split())
a = list(map(int,input().split()))
asr = sorted(a,reverse=True)
del asr[0:n-k]
ans = sum(asr)
print(str(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()))

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()))
b.sort()
d = b[0:a[1]]
print(sum(d))

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy



from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    a = inpl()
    ans = 0
    a.sort()
    for i in range(k):
        ans += a[i]
    print(ans)
    
if __name__ == "__main__":
    main()

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():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    print(sum((sorted(A)[0:K])))

if __name__ == "__main__":
    main()

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

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

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

list=sorted(num)
sum=0
for i in range(b):
    sum+=list[i]
print(sum)

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

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

print(ans)

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

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

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

Solution (Python):
import numpy as np
s = list(map(int, input().split()))
n = list(map(int, input().split()))
sumn = 0

n.sort()
for i in range(s[1]):
  sumn += n[i]

print(sumn)

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

ls = list(map(int, input().split()))
ans = 0

ls2 = sorted(ls)

for i in range(K):
  ans += ls2[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 = map(int,input().split())
n = map(int,input().split())
A = sorted(n)
print(sum(A[:K]))

Solution (Python):
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n,k=NM()
l=L()
l.sort()
print(sum(l[:k]))

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

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

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

P_li.sort()

sum=0

for i, name in enumerate(P_li):
    if i < K:
        sum+=name
print(sum)

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

s = 0

for i in range(K):
    t = min(p)
    s = s + t
    p.remove(t)

print(s)

Solution (Python):
N, K = map(int, input().split())
P = list(map(int, input().split()))
count = 0
new_list = []
while count < K:
    min = P[0]
    for i in P:
        if min > i:
            min = i
    new_list.append(min)
    P.remove(min)
    count += 1
print(sum(new_list))

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

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

Ans = 0
for i in range(K):
    minp = min(p)
    p.remove(minp)
    Ans +=minp
print(Ans)

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

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

Solution (Python):
try:
   n,k = map(int,input().split(" "))
   pi=list(map(int,input().split(" ")))
   pi.sort()
   cost=0
   i=0
   for i in range(k):
        cost+=pi[i]
   print(cost)
except:
    pass

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

N=NK[0]
K=NK[1]
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().strip().split()))

small = sorted(p)

result = 0
for i in range(k):
    result += small[i]

print(result)

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

Solution (Python):
a=input()
a=a.split()
K=int(a[1])

b=input()
b=b.split()
b=list(map(int, b))
b.sort()
z=0
n=0
for x in range(K):
  z=b[n]+z
  n=n+1
  
print(z)

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

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


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

Solution (Python):
n, k = map(int, input().split())
num_list = list(map(int,input().split()))
sum = 0
smallest = 1000
smallest_i = 0
for j in range(k):
    smallest = 1000
    for v, i in enumerate(num_list):
        if i < smallest:
            smallest = i
            smallest_i = v
    sum += smallest
    num_list[smallest_i] = 1000

print(sum)

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

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

Solution (Python):
N, K = map(int,input().split())
p = map(int,input().split())
newlist = sorted(p, reverse=False)
ans=[]
for i in range(1,K+1):
    ans.append(newlist[i-1])
print(sum(ans))

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):
def resolve():
    N, K = [int(i) for i in input().split()]
    A = sorted([int(i) for i in input().split()])
    sumA = 0
    for a in A[:K]:
        sumA += a
    print(sumA)


resolve()

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

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

print(sum)

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

Solution (Python):
(n,k) = input().split()
n = int(n)
k = int(k)
p = input().split()
p = [int(x) for x in p]
p.sort()
print(sum(p[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 += p[i]

print(sum)

Solution (Python):

import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


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

    ps = sorted(ps)

    print(sum(ps[:K]))


if __name__ == '__main__':
    main()

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

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

price=sorted(price)
alter_price = sorted(price)
ans = alter_price[:K]
answer=sum(ans)
print(answer)

Solution (Python):
import sys

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

N, K, *P = map(int, read().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(' ')))
if(K==1):
  print(min(P))
else:
  res=[]
  for i in range(K):
    res.append(min(P))
    P.remove(min(P))
  print(sum(res))

Solution (Python):
import heapq
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
print (sum(heapq.nsmallest(X[1], Y)))

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

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

print(ans)

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

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

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

    p.sort()

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

Solution (Python):
n,k=(int(x) for x in input().split())
p = list(int(x) for x in input().split())

p.sort()

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

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

Solution (Python):
import itertools

n, k = 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())
A = list(map(int, input().split()))
xxx = sorted(A)
zzz = 0
for i in range(K):
    zzz += xxx[i]
print(zzz)

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

Solution (Python):
a=input().split(" ")
b=input().split(" ")
c=[int(i) for i in b]
pay=sorted(c)
pay1=0

for i in range(int(a[1])):
    pay1=pay1+int(pay[i])

print(pay1)

Solution (Python):
n , x = map(int,input().split())
price_list = list(map(int,input().split()))
ld = sorted(price_list, reverse=False)
sum = 0
for i in range(x):
  sum += ld[i]
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=s+l[i]
print(s)

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 = input().split()
price = list(int(t) for t in input().split())
price_s = sorted(price)
total = sum(price_s[0:int(K)])
print(total)

Solution (Python):
class Bucket:
  def __init__(self, max_size):
    self.__max_size = max_size
    self.__busket = []
    self.__max = 0
    self.__busket_size = 0

  def add(self, price):
    if self.__busket_size < self.__max_size:
      self.__busket.append(price)
      self.__busket_size += 1
      self.__max = max(self.__max, price)
      return self

    if self.__max <= price:
      return self

    self.__busket.remove(self.__max)
    self.__busket.append(price)
    self.__max = max(self.__busket)

  def sum(self):
    return sum(self.__busket)

if __name__ == "__main__":
  n, k = map(int, input().split(' '))
  price_list = list(map(int, input().split(' ')))
  b = Bucket(k)
  for p in price_list:
    b.add(p)
  
  print(b.sum())

Solution (Python):
import numpy as np

n,k=np.array(list(map(int,input().split())))
p=np.array(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()
S=0
for i in range(K):
	S=S+P[i]
print(S)

Solution (Python):
n, k = map(int, input().split())
lst = sorted(list(map(int, input().split())))
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 = ans + P[i]
    

print(ans)

Solution (Python):
prices = []
total_fruits = 0
max_numb = 0

total_fruits, max_numb = input().split(' ')
tmp_prices = input().split(' ')
tmp_prices = [int(i) for i in tmp_prices]
tmp_prices.sort()
ans = 0
for i in range(int(max_numb)):
  ans += int(tmp_prices[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 = a + p[i]
print (a)

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

Solution (Python):
para_line = list(map(int,input().split(' ')))
input_line = list(map(int,input().split(' ')))
input_line.sort()
print(sum(input_line[:para_line[1]]))

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

array.sort()

suma=0
for i in range(K):
  suma=suma+array[i]
print(suma)

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().strip().split(" ") ) ;
arr = list ( map ( int , input().strip().split(" ") ) ) ; 
arr.sort() ;

print ( sum( arr[:K] ) );

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

p.sort()
p2 = []
for k in range(0,K):
    p2.append(p[k])

print(sum(p2))

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

Solution (Python):
N,K = map(int,input().split())
li = [int(i) for i in input().split()]
total = 0
 
for _ in range(K):
	total += min(li)
	li.remove(min(li))
 
print(total)

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

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

n = sorted(n)
sum = 0

for i in range(N):
    sum += n[i]
    if i == K-1:
        print(sum)
        exit()

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

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

t = 0
for e in range(K):
    t += l[e]

print(t)

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

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

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

pd = sorted(p)
total = 0

for i in range(k):
    total += pd[i]

print(total)

Solution (Python):
N,K = input().split()
N = int(N)
K = int(K)
p = list(map(int, input().split()))
p.sort()
i = 0
count = 0
while i<K:
  count+=p[i]
  i+=1
print(count)

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

for i in range(b):
  sum += d[i]

print(sum)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')


def solve():
    n, k = LI()
    p = LI()
    p.sort()
    print(sum(p[:k]))
    return



if __name__ == '__main__':
    solve()

Solution (Python):
tmp1 = input()
tmp2 = input()

tmp3 = tmp1.split(" ")
tmp4 = tmp2.split(" ")

N = int(tmp3[0])
K = int(tmp3[1])

for i in range(N):
    tmp4[i] = int(tmp4[i])

tmp4.sort()
out = 0

for i in range(K):
    out = out + tmp4[i]

print(out)

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

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

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

print(sum(p[:K]))

Solution (Python):
def main():
    N, K = [int(x) for x in input().split()]
    p = sorted([int(x) for x in input().split()])
    print(sum(p[:K]))
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

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

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


newlist = sorted(p)


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

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

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

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

print(sum(P[:K]))

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

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

x.sort()

i=0
S=0

while i<k:
    S+=x[i]
    i+=1

print(S)

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

def calc_minmum_money(money_list, K):
    money_list.sort()
    minmum_money_list = money_list[:K]
    return sum(minmum_money_list)

print(calc_minmum_money(money_list, 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())
value = list(map(int, input().split()))

value = sorted(value)


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

Solution (Python):

def is_possible(arr_sorted, k, money):
  sum = 0
  for i in range(k):
    sum += arr_sorted[i]
    if sum > money:
      return False   
  return True

N, K  = [int(v) for v in input().split()]
p_arr = [int(v) for v in input().split()]
right = 1000 * 1000
left = 0
p_arr.sort()
while( right -left > 1):
  mid = (left+right) // 2
  if is_possible(p_arr, K, mid):
    right = mid
  else:
    left = mid
print(right)

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(x) for x in input().split())
a=[int(x) for x in input().split()]
a.sort()
sum=0
n=0
while k>n:
    sum+=a[n]
    n+=1
print(sum)

Solution (Python):


numbers = input().split(" ")
n = int(numbers[0])
k = int(numbers[1])

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

p.sort()

r = 0

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

print(r)