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):
def mergesort(l):
    n = len(l)
    if(n == 1):
        return l
    elif(n <= 2):
        if(l[0] > l[1]):
            return [l[1],l[0]]
        else:
            return l
    else:
        tmp1 = mergesort(l[:n//2])
        tmp2 = mergesort(l[n//2:])
        x = n//2
        y = n-x
        l = []
        for i in range(n):
            if(tmp1[-x] < tmp2[-y]):
                l.append(tmp1[-x])
                x -= 1
            else:
                l.append(tmp2[-y])
                y -= 1
            if(x*y == 0):
                if(x == 0):
                    l += tmp2[-y:]
                else:
                    l += tmp1[-x:]
                break
        return l
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = mergesort(p)
q = 0
for i in range(k):
    q += p[i]
print(q)

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

sum_price = 0

for i in range(K):
    min_price = min(prices)
    sum_price += min_price
    prices.remove(min_price)

print(sum_price)

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

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

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

p_sort = sorted(p)

ans = 0
cnt = 0
for _ in p_sort:
    ans += _
    cnt += 1

    if cnt >= k:
        break

print(ans)

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

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

print(str(ans))

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

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

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

 
   
list = heapq.nsmallest(k, p)

print(sum(list))

Solution (Python):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,k = 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())
p = list(map(int, input().split()))
p = sorted(p)

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

print(ans)

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

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

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

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

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

price=sorted(p)

pk=[price[k] for k in range(K)]
print(sum(pk))

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



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




p.sort()


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

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

A.sort()
a = sum(A[0:K])
print(a)

Solution (Python):
n,k = map(int,input().split(' '))
p = list(map(int,input().split(' ')))
ans=0
import heapq
heapq.heapify(p)
for _ in range(k):
    ans += heapq.heappop(p)
print(ans)

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

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

Solution (Python):
def juice(k,a):
    return sum(a[:k])

if __name__ == "__main__":
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    a.sort()
    print(juice(k,a))

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

P.sort()

count = 0

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

print("{}".format(count))

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

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

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

b0=input().split()
nl=[]
for i in range(n):
  nl.append(int(b0[i]))
  
nl.sort()
ans=0
for i in range(k):
  ans+=nl[i]
print(ans)

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




price.sort()



res = 0

for i in range(data[1]):

    res += price[i]

print(res)

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 = ans+p[i]
    
print(ans)

Solution (Python):
n = input().split()
N = int(n[0])
K = int(n[1])

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

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

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

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

print(sum)

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

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

Solution (Python):
[_n, _k] = list(map(int, input().split(" ")))
_fruits = list(map(int, input().split(" ")))
_fruits.sort()
_sum = 0
for _i in range(_k):
  _sum += _fruits[_i]
print(_sum)

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

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

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

ans = 0

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

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

Solution (Python):
if __name__ == "__main__":
    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())
print(sum(sorted(map(int,input().split()))[:K]))

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

p.sort()

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

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

p.sort()

result = 0

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

print(result)

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline().strip()

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


main()

Solution (Python):

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

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

total = 0

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

print(total)

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

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

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

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

Solution (Python):
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    A=list(map(int,input().split()))
    N=A[0]
    K=A[1]
    p=list(map(int,input().split()))
    p.sort()
    kingaku=0
    for i in range(K):
        kingaku+=p[i]
    print(kingaku)

if __name__ == '__main__':
    main()

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

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

p.sort()

sum=0
count=0

for i in range(N):
    sum+=p[i]
    count+=1
    if count==K:
        break
print(sum)

Solution (Python):

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

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

p.sort()

print (sum(p[:K]))

Solution (Python):
import sys

data = sys.stdin.readlines()
_data = data[0].split()
kakaku = data[1].split()
ans = 0

kazu = int(_data[1])
list_int = [int(n) for n in kakaku]
list_int.sort()
for i in range(kazu):
  ans += list_int[i]
  
print(ans)

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

print(cnt)

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

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

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

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

Solution (Python):
temp1 = input().split(" ")
temp2 = input().split(" ")

n = int(temp1[0])
k = int(temp1[1])

prices = [int(i) for i in temp2]

prices.sort()

print(sum(prices[:k]))

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

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

Solution (Python):
_in1 = [int(x) for x in input().split(' ')]
n = _in1[0]
k = _in1[1]

result = 0
_list = [int(x) for x in input().split(' ')]
_list.sort()

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

print(result)

Solution (Python):

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

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

Solution (Python):
a = input().split()
N = int(a[0])
K = int(a[1])
list = []
price = 0
b = input().split()
for i in range(len(b)):
    list.append(int(b[i]))
list = sorted(list)
for i in range(K):
    price+= list[i]
print(price)

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

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

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

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

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 = SUM + p[i]
print(SUM)

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

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

newP = sorted(p)
print(sum(newP[0:K]))

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

Solution (Python):

n, k = map(int, input().split())
p = list(map(int, input().split()))
p1 = sorted(p)[0:k]


print(sum(p1))

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

Solution (Python):
fruits = [int(i) for i in input().split()]
prices = sorted([int(i) for i in input().split()])
value = 0
for i in range(0, fruits[1]):
    value += prices[i]
print(value)

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

p=sorted(p)

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

Solution (Python):
import numpy as np


def main(K, M):
    ans = 0
    p.sort()
    for i in range(K):
        ans += p[i]
    return ans


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

Solution (Python):
if __name__ == "__main__":
    N, K = list(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())
pList = list(map(int, input().split()))

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

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

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

Solution (Python):
def sums(l):
	s = 0
	for v in l:
		s += v
	return s

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

print(sums(a[: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())
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()

sum=0

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

print(sum)

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

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

print(c)

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

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

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(0, K): 
    ans += P[i]

print(ans)

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

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

Solution (Python):
nums = [int(e) for e in input().split()]
p = [int(e) for e in input().split()]
p.sort()
print(sum(p[0:nums[1]]))

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

p_list.sort()
Ans=0

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

print(Ans)

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

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

tot=0
for _ in range(k):
	tot+= p_s.pop(0)

print(tot)

Solution (Python):
import sys
from io import StringIO
import unittest


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

    p.sort()

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 3
50 100 80 120 80"""
        output = """210"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 1
1000"""
        output = """1000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

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 = []
for p in map(int,input().split()):
  P.append(p)
list.sort(P, reverse=True)
s = 0
for k in range(K):
  s += P.pop()
print(s)

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

m = sorted(p)

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

print(ans)

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

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

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

p.sort()

summ=0

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

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

i=0
price=0
while i<k:
    price+=p[i]

    i+=1
    
print(price)

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

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

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

buy = sorted(p)
price = sum(buy[:K])
print(price)

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

Solution (Python):



if __name__ == '__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)

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

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

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

sortp = sorted(p)
sum=0
for k in range(K):
    sum=sum+sortp[k]

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

p.sort()
ans = 0
cnt = 0
for i, value in enumerate(p):
    if i < k:
        ans += value
print(ans)

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

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

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

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

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


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

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

Solution (Python):
from itertools import combinations

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

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

print(ans)

Solution (Python):

n, k = (int(x) for x in input().split())

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

p_list.sort()

sum_ = 0

for i in range(k):
    sum_ = sum_ + int(p_list[i])

print(sum_)

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

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

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

l.sort()

sum=0

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

print(sum)

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

print(sum)

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

price = sorted(price)

print(sum(price[:k]))

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

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

f_p.sort()
b_p = f_p[:K]

ans = sum(b_p)
print(ans)

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

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

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

p_int.sort()

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

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

res = 0

for k in range(K):
    t = p[0]
    c = 0
    for i in range(len(p)):
        if t > p[i]:
            t = p[i]
            c = i

    res += p.pop(c)

print(res)

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

p.sort()
t=0
for q in p[0:k]:
    t+=q
print(t)

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

N = i[0]
K = i[1]

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

p.sort()
sum = 0
for iter in range(K):
    sum += p[iter]

print(sum)

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

p.sort()

print(sum(p[:n]))

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

pd = sum(p[0:K])

print(pd)

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

ret=0
for i in range(K):
    ret+=list[i]
print(ret)

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

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

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

p = [int(n) for n in p]

p.sort()

res = 0

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

print(res)

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

newp0 = sorted(p)
newp1 = newp0[0:K]

print(sum(newp1))

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

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()))
sort_p = sorted(p)
total = sum(sort_p[0:k])
print(total)

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

Solution (Python):

"""AtCoder Beginner Contest 171: B - Mix Juice
https://atcoder.jp/contests/abc17/tasks/abc171_b
"""


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

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


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    total1 = list(map(int, input().split()))
    total = list(map(int, input().split()))

    num = total1[1]

    s_total = sorted(total)

    money = 0
    for i in range(num):
        money += s_total[i]

    print(money)


if __name__ == '__main__':
    main()

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

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

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

print(sum(L[:k]))

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

Solution (Python):
NK = input().split()
N = int(NK[0])
K = int(NK[1])

ps = input().split()

p = []

for i in range(N):
    p.append(int(ps[i]))

ans = 0


rp = sorted(p)

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

print(ans)

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

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

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

Solution (Python):

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

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

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

        return ans

if __name__=="__main__":
        ans = main()
        print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)

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

l.sort()

print(sum(l[:k]))

Solution (Python):
x,y = map(int,input().split())
li = list(map(int, input().split()))

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

Solution (Python):
n,k=map(int,input().split())
p=list(map(int,input().split()))
P=sorted(p)
l=[]
cnt=0
for i in P:
  cnt+=1
  l.append(i)
  if cnt==k:
    break
print(sum(l))

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

list.sort()

print(sum(list[:k]))

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


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

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

Solution (Python):


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

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys

l = sys.stdin.readline().rstrip('\n').split(' ')
N = int(l[0])
K = int(l[1])

l = sys.stdin.readline().rstrip('\n').split(' ')
prices = [int(i) for i in l]
prices.sort()

print(sum(prices[:K]))

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

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

print(total)

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

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

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

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

l=sorted(p)[:K]
print(sum(l))

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

p.sort()
cnt =0

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

print(cnt)

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

p.sort()

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

print(ans)