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):
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case 


def solve(n, k, p):
    return sum(sorted(p)[:k])


if __name__ == "__main__":
    n, k = arr_in()
    p = arr_in()
    out(solve(n, k, p))

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    n,k=map(int,readline().split())
    p=list(map(int,readline().split()))

    print(sum(sorted(p)[:k]))
    
if __name__=="__main__":
    main()

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

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


import copy
import random
import bisect 
import fractions 
import math
import sys
import collections
from decimal import Decimal 

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
p = LI()

p.sort()

ans = sum(p[:K])
print(ans)

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

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

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

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

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



def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    ret = sum(A[:M])

    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
import heapq

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

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

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

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

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 = sorted(p)
p_k = p_sort[:k]

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())
a=[int(x) for x in input().split()]
a.sort()
ans=0
for i in range (k):
    ans+=a[i]
print(ans)

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

def main():
    number_of_types,number_of_purchase = map(int,input().split())
    price_list = list(map(int,input().split()))
    price_list.sort()
    sum_price = sum([item for suffix,item in enumerate(price_list) if suffix < number_of_purchase])
    print(sum_price)
if __name__ == "__main__":
    main()

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

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

P = map(int, raw_input().split())
P.sort()

print sum(P[:K])

Solution (Python):
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = sorted(y)
Sum = 0
for i in range(0,x[1]):
    Sum += z[i]
    
print(Sum)

Solution (Python):
N,K = map(int, input().split())
P = list(map(int,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())
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())
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())
p = list(map(int,input().split()))
s = 0

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

Solution (Python):
import numpy as np

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

prices_arr = np.array(prices)
answer = prices_arr[0:k].sum()

print(answer)

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

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

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

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

memo = {}

def minPrice(n, k):
    if (n, k) in memo:
        return memo[(n, k)]
    if n < k:
        return INF
    if k == 0:
        return 0
    take = prices[n-1] + minPrice(n-1, k-1)
    skip = minPrice(n-1, k)
    ans = min(INF, take, skip)
    memo[(n, k)] = ans
    return ans

print(minPrice(N, 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(' ')]
lis=[int(x) for x in input().split(' ')]

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

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

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

print(ans)

Solution (Python):
N, K = map(int, input().split())
lst = sorted([int(x) for x in input().split()])
print(sum(lst[: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):
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  n, k = I()
  p = LI()
  p.sort()
  ans = 0
  for i in range(k):
    ans += p[i]
  print(ans)
  
if __name__ == '__main__':
  main()

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

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    list.sort(p)
    print(sum(p[0: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):
N , K = map(int,input().split())
price = list(map(int,input().split()))

price.sort()

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

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

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

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

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

print(sum(p[:K]))

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

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

r = sum(sorted(l)[:k])

print(r)

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

c.sort()
sum = 0
for i in c[0:int(a[1])]:
    sum += int(i)
print(sum)

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

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

Solution (Python):


hairu = input()
koi = hairu.split(" ")
ne = input()
kak = ne.split()
ka = []
for ne in range(len(kak)):
    ka.append(int(kak[ne]))
ka.sort()
total = 0
for i in range(int(koi[1])):
    total += int(ka[i])
print(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)[0:K]))

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

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


ps = sorted(ps)
print(sum(ps[:k]))

Solution (Python):


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

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

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

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


main()

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

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

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

    p.sort()
    print(sum(p[:K]))
if __name__ == '__main__':
    solve()

Solution (Python):
n,k = map(int,input().split())
p = [int(p) for p in input().split()]
p.sort()
a = 0
s = 0
while a+1 <= k:
  s += int(p[a])
  a += 1
print(s)

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

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

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

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

print(total)

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

p.sort()
p = p[0: K]

print(sum(p))

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

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

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

print(ans)

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

print(ans)

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

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

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

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

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

print(sum)

Solution (Python):
import sys
import math


from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n,k=iia()
arr=iia()
arr.sort()
s=0
for i in range(k):
    s+=arr[i]
print(s)

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

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

p.sort()
p = p[:k]
ans = sum(p)
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()
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 = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
print(sum(sorted(nums)[:K]))

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

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

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

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

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

p.sort()

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

Solution (Python):

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


pl.sort()
print(sum(pl[: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):
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,k = (int(x) for x in input().split())
seq = sorted((int(x) for x in input().split()))
print(sum(seq[:k]))

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

print(r)

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

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

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

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

p.sort()

sum = 0

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

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

Solution (Python):

import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]





n,k=value()
a=sorted(array())

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

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

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

s = 0

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

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

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

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

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

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

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

Solution (Python):




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

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

p_sort = p.sort()

ans = sum(p[:n])

print(ans)

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

Solution (Python):
_,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):
inp1 = input()
inp2 = input()

lists1 = inp1.split()
lists2 = inp2.split()

N = int(lists1[0])
K = int(lists1[1])
values = sorted([int(i) for i in lists2])

result = sum(values[:K])

print(result)

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

s = input().split(" ")
p = []
for S in s:
    p.append(int(S))

sum = 0
for i in range(K):
    n = p.index(min(p))
    sum += p[n] 
    p.pop(n)

print(sum)

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

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

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

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

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

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

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

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

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

Solution (Python):
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n, k = rl()
    P = rl()
    print (sum(sorted(P)[:k]))






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

Solution (Python):


def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, K = MII()
    p = LII()

    p.sort()

    print(sum(p[:K]))

if __name__ == '__main__':
    main()

Solution (Python):
import heapq
n,k = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
heapq.heapify(P)
for i in range(k):
    ans += heapq.heappop(P)
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()
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()))

p.sort()

print(sum(p[:K]))

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

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

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

Solution (Python):
N, K = map(int, input().split())
values = sorted([int(i) for i in input().split()])
sum_least = 0
for i,value in enumerate(values):
    if i > K-1:
        break
    sum_least += values[i]

print(sum_least)

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

kMin = sum(fruits[:k])
print(kMin)

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

P.sort()

print(sum(P[:K]))

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

Solution (Python):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
sort_list = sorted(p_list)
ans = 0

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	N,K = inputMap()
	p = inputList()

	p.sort()

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

	print(ans)




if __name__ == "__main__":
	main()

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

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

p_s = sorted(p)



sum_v = sum(p_s[0:k])

print(sum_v)

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):
from typing import List


def main():
    _, K = map(int, input().split())
    p_lst: List[int] = list(map(int, input().split()))

    p_lst.sort()

    total: int = 0
    total = sum(p_lst[0: K])

    print(total)


if __name__ == "__main__":
    main()

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

price_list.sort()
sum = 0

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

print(sum)

Solution (Python):

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

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

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

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

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

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

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

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

list_buy = []

for i in range(k):
    min = 1001
    for j in range(n):
        if p[j] < min:
            min = p[j]
            ind = j
    list_buy.append(min)
    p[ind] = 1000

print(sum(list_buy))

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

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

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

print(sum(p[:K]))

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

print(sum(P[:K]))

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

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()))
pin = p.sort()
print(sum(p[:K]))

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

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

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

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

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

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

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

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

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

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

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

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


LI = lambda: list(map(int, input().split()))


N, K = LI()
P = LI()


def main():
    P.sort()
    ans = sum(P[:K])
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys


def log(s):
    
    pass


def output(x):
    print(x, flush=True)


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


def main():
    n, k = tuple(input_ints())
    ps = input_ints()
    ps.sort()
    print(sum(ps[0:k]))


main()

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