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

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

Solution (Python):
import math
import sys

def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))

def seive_primes(n):
    flag=[0]*(n+10)
    flag[1]=flag[0]=1
    i=2
    while i*i<=n+1:
        if flag[i]==0:
            j=i*i
            while j<=n+1:
                flag[j]=1
                j+=i
        i+=1
    return flag

def is_prime(n):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)

def alphbates():
    return "abcdefghijklmnopqrstuvwxyz"

def inp():
    ls=list(map(int,input().split()))
    return ls

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

n,k=mult_inp()
ls=inp()
ls.sort()
print(sum(ls[:k]))

Solution (Python):
import sys
input = sys.stdin.readline
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())
nums = [int(x) for x in input().split()]
nums.sort()
print(sum(nums[:k]))

Solution (Python):
def addAndDeleteMin():
	global ans
	global p
	minv = min(p)
	ans += minv
	p.remove(minv)

n,k = map(int,input().split())
p = [int(x) for x in input().split()]
ans = 0
for i in range(k):
	addAndDeleteMin()
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    P = sorted(list(map(int, input().split())))
    res = sum(P[:k])
    print(res)


if __name__ == '__main__':
    resolve()

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

A.sort()

Sum = 0

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

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

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

Solution (Python):
def main():
    N, K = map(int, input().split())
    *p, = map(int, input().split())
    p.sort()
    print(sum(p[0:K]))
    return


main()

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

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

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

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

Solution (Python):
N,K=map(int,input().split())
S=[0]*(N+1);w=0
P=list(map(int,input().split()))
for i in range(1,N+1):
  S[i-1]=[i,P[i-1]]
S[-1]=[0,1000]
S.sort(key=lambda x: x[1])

for i in range(K):
  w=w+S[i][1]
print(w)

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

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

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	n, k = tin()
	
	al = lin()
	al.sort()
	ret = sum(al[:k])
	print(ret)
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

Solution (Python):


inp=input().split()
a,b=int(inp[0]),int(inp[1])
arr=list(map(int,input().split(" ")))
arr.sort()
print( sum(arr[:int(b)]))

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

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

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

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

price.sort()
print(sum(price[0:K]))

Solution (Python):
syu,ko = map(int,input().split())

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

jyu_list.sort()

goukei = 0

for i in range(ko):
    goukei = goukei+jyu_list[i]

print(goukei)

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

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

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

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

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

P.sort()

res = sum(P[:K])
print(res)

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

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

print(ans)

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

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

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

print(sum(p[:k]))

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()


from collections import deque  
def main():
    n, k =map(int,input().split())
    p = list(map(int,input().split()))
    p.sort()
    s = sum(p[:k])
    print(s)	


if __name__=='__main__':
    main()

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

    N, K = [int(x) for x in input().split(' ')]
    L2 = sorted([int(x) for x in input().split(' ')])

    pick_sum = 0
    for i in range(K):
        pick_sum = pick_sum + L2[i]

    print(pick_sum)

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

print(int(sum(sorted(p)[:k])))

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

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

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

print(sum(sorted(prices)[:k]))

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

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

Solution (Python):


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

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

prices.sort()

print("%d" % sum(prices[:k]))

Solution (Python):
import sys



def solve(n):
    
    NCHARS = int(26)
    MAXVAL = NCHARS
    ndigs = 1
    while n > MAXVAL:
        ndigs += 1
        n -= MAXVAL
        MAXVAL *=  NCHARS
    
    
    n -= 1
    result = ''
    while n > 0:
        
        
        result += chr(n%NCHARS + ord('a'))
        n //= NCHARS
        
        
        
    if len(result) < ndigs:
        result += ''.join(['a' for i in range(ndigs-len(result))])
    print(''.join([c for c in result][::-1]))
        

        


if __name__ == '__main__':
    IN = [x.strip() for x in sys.stdin.readlines()]

    n,k = [int(x) for x in IN[0].split(' ')]
    vals = [int(x) for x in IN[1].split(' ')]
    print(sum(sorted(vals)[:k]))

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

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

price.sort()

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

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

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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

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

Solution (Python):
if __name__ == "__main__":
    N,k = [int(item) for item in input().split()]
    price_arr = [int(p) for p in input().split()]
    print(sum(sorted(price_arr)[:k]))

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

Solution (Python):
import sys
import math


input = sys.stdin.readline
 

def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))



n,k=invr()
ara=inara()

ara.sort()

ans=0

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

print(ans)

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

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

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

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

Solution (Python):
x = input()
y = input()

a = list(map(int, x.split()))
b = list(map(int, y.split()))

K = a[1]
b = sorted(b)

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

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

jpy = 0

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

print(jpy)

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

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

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

print(res)

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

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

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

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

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

array = list(map(int, input().split()))
array.sort()
total = 0

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

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

p.sort()

print(sum(p[:k]))

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

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

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

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

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

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


if __name__ == "__main__":
    main()

Solution (Python):

import sys
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n, k = MI()
mylist = LI()
mylist.sort()
print(sum(mylist[0:k]))

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline

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

    print(sum(p[:k]))


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):



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

print(sum(p[:K]))

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

for i in range(k):
    ans = ans + s[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):
import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


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


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


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

new_list = sorted(list)
pay = 0

for i in range(K):
    pay = pay + new_list[i]
print(pay)

Solution (Python):
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    print sum(p[:k])
    return




n, k = RA()
p = sorted(RA())
solve()

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

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

Solution (Python):

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

p.sort()


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

print(sum)

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

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

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

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

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

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

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

  price.sort()

  part = price[0:K]

  print(sum(part))

if __name__ == '__main__':
  main()

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

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

Solution (Python):

import sys
import numpy as np
input = sys.stdin.readline
x,y = map(int,input().split()) 
A= list(map(int,input().split()))
A.sort()
print(sum(A[:y:]))

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

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

print(ans)

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

Solution (Python):
num, buy = [int(x) for x in input().split(' ')]

p_arr = map(int, input().split(' '))

sp = sorted(list(p_arr))

print(sum(sp[:buy]))

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

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

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

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

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

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

print(sum(sorted(price_list)[0:k]))

Solution (Python):



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

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

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

Solution (Python):
info = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

q.sort()

ans = 0;
for i in range(info[1]):
  ans += q[i]

print(ans)

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

sorted_new = sorted(p)

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

print(ans)

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

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

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

Solution (Python):
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for i,v in enumerate(p):
    ans += v
    if i == K - 1:
        print(ans)
        exit()
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,*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()
print(sum(p[:K]))

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

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

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

price=price[:k]
print(sum(price))

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

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

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

Solution (Python):
import collections

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

for i in range(0,s[1]):
	a.append(p[i])
print(sum(a))

Solution (Python):
import heapq
n, k = map(int, input().split())
fruits = list(map(int, input().split()))
heapq.heapify(fruits)
print(sum(heapq.nsmallest(k, fruits)))

Solution (Python):


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

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

array.sort()

del array[b:]

print(sum(array))

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

Solution (Python):



def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    
    N, K = list(map(int, input().split()))
    p = list(map(int, input().split()))

    return N, K, p


def main(K: int, p: list) -> None:
    """
    求解処理.

    Args:
        K (int): 購入する果物の種類
        p (list): 各果物の価格
    """
    
    sorted_p = sorted(p)
    ans = sum(sorted_p[:K])

    
    print(ans)


if __name__ == "__main__":
    N, K, p = get_input()
    main(K, p)

Solution (Python):



def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    
    N, K = list(map(int, input().split()))
    p = list(map(int, input().split()))

    return N, K, p


def main(K: int, p: list) -> None:
    """
    求解処理.

    Args:
        K (int): 購入する果物の種類
        p (list): 各果物の価格
    """
    
    sorted_p = sorted(p)
    ans = sum(sorted_p[:K])

    
    print(ans)


if __name__ == "__main__":
    N, K, p = get_input()
    main(K, p)

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

Solution (Python):
_,b,*c=map(int,open(0).read().split());print(sum(sorted(c)[:b]))

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

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

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

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

p.sort()

print(sum(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())
p = [int(x) for x 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 = list(map(int,input().split()))

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

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

print(sum)

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

print(sum(sorted(li_p)[:k]))

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

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

p_list.sort()

num = 0

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

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

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

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

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

B.sort()

print(sum(B[:A[1]]))

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

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

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

print(sum(arr[:k]))

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

prices.sort()

sum = 0
for i in range(K_ko):
    sum += prices[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([int(i) for i in input().split()])
print(sum(p[:k]))

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

Solution (Python):
a,b = [int(i) for i in input().split()]

l = sorted([int(i) for i in input().split()])

print(sum(l[:b]))

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

Solution (Python):
def quick_sort(plices):
    if len(plices) == 1:
        return plices


    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    
    sorted_plices = sorted(plices)
    
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    print(sum(sorted(p)[:K]))
    return



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

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
data = stdin.readlines()

n = list(data[0].split())[0]
k = int(list(data[0].split())[1])

l = [int(s) for s in data[1].split()]
l_sorted = sorted(l)

i = 1
price = 0
while i <= k:
    price += l_sorted[i-1]
    i += 1

print(price)

Solution (Python):
import sys



inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))





def solve():
	n, k = read(); arr = sorted(read())
	print(sum(arr[:k]))



if __name__ == "__main__":
	solve()

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

a.sort()

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

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

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

q=sorted(p)

print(sum(q[:K]))

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

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

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

Solution (Python):
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')


if __name__ == '__main__':
    _, K = it()
    F = it()
    F.sort()
    print(sum(F[:K]))

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

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

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

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

Solution (Python):
import sys
input = lambda: 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=map(int,input().split())
a=[int(o) for o in input().split()]
b=sorted(a)
ans=0
for i in range(k):
    ans+=b[i]
print(ans)

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

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

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

p.sort()

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