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

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')

def main():
    N,K = MI()
    price_list = LI()
    price_list.sort()
    count = 0
    ans = 0
    for p in price_list:
        ans+=p
        count+=1
        if count == K:
            print(ans)
            break


if __name__ == '__main__':
    main()

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

Solution (Python):
from numpy import sort

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

num_list.sort()

ans = sum(num_list[:b])

print(ans)

Solution (Python):
shurui, kosuu = [int(idx) for idx in input().split()]
price = [int(idx) for idx in input().split()]

price.sort()
result = 0
for idx in range(kosuu):
  result += min(price)
  price.remove(min(price))
  
print(result)

Solution (Python):
import math

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

p.sort()

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

print(ans)

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

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

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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


main()

Solution (Python):

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

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

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

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

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

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

print(count)

Solution (Python):


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

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, k = LI()
    p = LI()
    q = sorted(p)
    ans = 0
    for i in range(k):
        ans += q[i]
    print(ans)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
n, k = [int(x) for x in 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()
ans = 0
for i in range(K):
    ans += p[i]
print(ans)

Solution (Python):
N,K = map(int,input().split())
while True:
    try:
        listp=list(map(int,input().split()))
    except:
        break;
listp.sort()
print(sum(listp[: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):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()
val = 0
for i in range(0,a[1]) :
  val = val + b[i]
print(val)

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

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

Solution (Python):
import math
from collections import Counter

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

s = sorted(P)[0:K]
ans = 0
for i in s:
    ans = ans + i

print(ans)

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

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

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

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

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

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

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

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

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

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

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

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

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

print(ans)

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

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

li = sorted(li)

ans = 0
for t in range(k):
    ans += li[t]

print(ans)

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

if __name__ == "__main__":
	main()

Solution (Python):

def resolve():
  N, K = map(int, input().split(" "))
  p = [int(x) for x in input().split(" ")]
  p.sort()

  print(sum(p[:K]))

if __name__ == "__main__":
  resolve()

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

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

print(count)

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

print(sum(p[:K]))

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

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

ans=0

p.sort()

for i,j in enumerate(p):
  ans+=j
  if i+1==K:
    break
    
print(ans)

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

P1 = sorted(P)
P2 = P1[:K]
print(sum(P2))

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

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

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

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

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

print(num)

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

if n == 1:
    print(fruits[0])
else:
    fruits.sort()
    print(sum(fruits[:k]))

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

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

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

print(ans)

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

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

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

fruit = 0
for i in range(nk[1]):
    fruit += p[i]

print(fruit)

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

Solution (Python):
import numpy as np
import math
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[0:K]))

Solution (Python):
a,b = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
a = []
for i in range(b):
  a.append(p[i])
  
print(sum(a))

Solution (Python):
import sys

N, K = map(int, sys.stdin.readline().strip().split())
P = list(map(int, sys.stdin.readline().strip().split()))

ans = 0
for i, p in enumerate(sorted(P)):
    if i == K:
        break
    ans += p

print(ans)

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

print(ans)

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

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

p.sort()

ans = 0

for i in p[:K]:
  ans += i

print(ans)

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

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

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

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

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

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

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

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

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

p_list.sort()




print(sum(p_list[:k]))

Solution (Python):
import math
import sys

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

A_sort = sorted(A)

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

print(ans)

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

Solution (Python):

n, k = 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()))
cnt = 0
ans = 0
for e in sorted(p):
  ans += e
  cnt += 1
  if cnt==k:
    break
print(ans)

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

p = sorted(p)
ans = 0

for a in p[:K]:
    ans += a
    

print(ans)

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

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

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

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines




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

print(sum(P[:k]))

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

p.sort()
ans=0

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

print(ans)

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

Solution (Python):

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

ans = 0

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

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

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

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

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

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

p.sort()

print(sum(p[:K]))

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

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

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

Solution (Python):
x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
p=input()
p0=p.split()
pl=[int(n) for n in p0]
pl.sort()
print(sum(pl[:k]))

Solution (Python):
import sys

(n, k) = map(int, sys.stdin.readline().strip().split())
list_input = list(map(int, sys.stdin.readline().split()))

list_input.sort()

print(sum(list_input[:k]))

Solution (Python):
n,k=map(int,input().split())
p=[0]*n
p=list(map(int,input().split()))
p=sorted(p)
ans=sum(p[:k])
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 sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,K = map(int, readline().split())
A = list(map(int,readline().split()))
B =sorted(A)
print(sum(B[:K]))

Solution (Python):
import numpy as np


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

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

Solution (Python):
N, K = (int(s) for s in input().rstrip().split())
nums = [int(s) for s in input().rstrip().split()]
sorted_nums = sorted(nums)
print(sum(sorted_nums[:K]))

Solution (Python):

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

p.sort()


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

print(ans)

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

Solution (Python):
N,K = map(int, input().split())
L = list(map(int, input().split()))
Ans=0
for i in range(K):
    Ans +=  min(L)
    L.pop(L.index(min(L)))
print(Ans)

Solution (Python):
import sys



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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

INF = float("inf")


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

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

print(sum(ps[:k]))

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

a = list(map(int,input().split()))
heapq.heapify(a)
S = 0
for i in range(K):
    mina = heapq.heappop(a)
    S += mina
print(S)

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, k = MI()
    p = sorted(LI())[0:k]
    print(sum(p))

if __name__ == '__main__':
    main()

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

Solution (Python):

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

p.sort()

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

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

print(sum)

Solution (Python):
import numpy as np

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

X = 0
for i in range(K):
    index = np.argmin(P)
    X += P[index]
    P[index] = 10000
print(X)

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

a=sorted(a)
ans=0

for b in range(k):
  ans+=a[b]
  
print(ans)

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

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

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

lst.sort()

ans = sum(lst[0:k])

print(ans)

Solution (Python):
n, k = map(int,input().split())
ps = list(map(int, input().split()))
newlist = sorted(ps)
ans=0
i=0
for p in newlist:
    ans+=p
    if k-1==i:
        break
    i+=1
print(ans)

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

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

price_list.sort()

print(sum(price_list[:k]))

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

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

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

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

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

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

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

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

print(sum)

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

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

Solution (Python):

import sys
import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    pp = sorted(p)
    ans = sum(pp[:K])
    print(ans)
    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())
p = list(input().split())
for i,e in enumerate(p):
    p[i] = int(e)
p.sort()
money = 0
for i in range(K):
    money += int(p[i])

print(money)

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

l_sort = l.sort()

ans = sum(l[:m])

print(ans)

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

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

print(ans)

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

p = sorted(p)

s = 0
for i in p[:k]:
    s += i

print(s)

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

P.sort()
tgt_P = P[:K]

print(sum(tgt_P))

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

ps = sorted(p)

print(sum(ps[:k]))

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

P.sort()

ans = 0

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

print(ans)

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

print(sum(p[:k]))

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

Solution (Python):
def main():
    N,K = map(int,input().split())
    p = [0] * N
    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):
import numpy as np

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

p.sort()

p_array = np.array(p)
ans_list = p_array[:K]
ans = ans_list.sum()

print(ans)

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

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

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

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

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

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

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

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


if 'unittest' not in globals():
    resolve()

Solution (Python):
def solve():
	N, K = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	for i in range(min(N, K)):
		ans += arr[i]
	return ans

def main():
	
	print(solve())


if __name__ == '__main__':
	main()

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

Solution (Python):
import numpy as np

def main():
    
    n,k = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()
    print(np.sum(p[:k]))
    

if __name__ == '__main__':
    main()

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

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

p = sorted(p)

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

print(ans)

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

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

Solution (Python):
import numpy as np
N, K=list(map(int, input().split()))
p=np.array(list(map(int, input().split())))
p=np.sort(p)
print(np.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):
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,k=get_ints()
c=get_array()
a=sorted(c)
b=a[:k]
print(sum(b))

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

p.sort()

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

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

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

    ans = sum(P[0:K])

    print(ans)


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
import sys
import numpy as np

readline = sys.stdin.readline

n, k = map(int, input().split())
p = np.array(readline().split(), dtype=np.int64)
p.sort()
ans = np.sum(p[:k])
print(ans)

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

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

li.sort()

ans = 0

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

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

Solution (Python):




import sys
input = sys.stdin.readline



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

    p = sorted(p)
    p = p[:K]

    res = sum(p)

    print(res)



main()

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

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

list_p.sort()

print(sum(list_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()))

ps = sorted(p)

ans=0

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

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

p.sort()

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

print(ans)

Solution (Python):
n,k = map(int,input().split())
a = [i for i in map(int,input().split())]
a = sorted(a)
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):
N, K = map(int, input().split(" "))

p = list(map(int, input().split(" ")))
pa = sorted(p)

print(sum(pa[:K]))

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

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

print(sums)

Solution (Python):
__DEUBG__ = 0

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

if __DEUBG__:
    print(N, K)
    print(prices)

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

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

Solution (Python):
s = str(input())
d = s.split()
n = int(d[0])
k = int(d[1]) 
ps = str(input())
p = ps.split()
l = []
ans = 0
for i in p:
	i = int(i)
	l += [i]
l.sort()
for j in l[0:k]:
	ans += j
print(ans)