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-----
5 3
50 100 80 120 80

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

Solutions:
n = [ int(i) for i in  input().split() ]
p = [ int(i) for i in input().split() ]

p = sorted(p)
val = sum( p[:n[1]] )
print(val)





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

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

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

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

p.sort()
en = 0

for i in range(0,K):
	en += p.pop(0)
print(en)

n,k = map(int, input().split())
price = list(map(int, input().split()))
count = 0
sum = 0

while count < k:
  abc = min(price)
  sum += abc
  price.pop(price.index(abc))
  count += 1 
  
print(sum)

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

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

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

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


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


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

print(sum(poe[:K]))


def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(map(int, input().split()))
def i_row(N): return [int(input()) for _ in range(N)]
def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]

n,k=i_map()
pp=i_list()
pp.sort()
ans=0
for i in range(k):
    ans+=pp[i]
print(ans)

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

_, k = input().split()
k = int(k)
p = sorted(list(int(i) for i in input().split()))
print(sum(p[0:k]))

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


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

p = sorted(p)
val = sum(p[:n[1]])
print(val)



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

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

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

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

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


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

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

a = list(map(int,input().split()))
N = a[0]
K = a[1]
p = list(map(int,input().split()))

p.sort()
x = 0

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


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)

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)
from collections import deque

# スペース区切りの整数の入力
N, K = list(map(int, input().split()))
#配列の入力
data = list(map(int, input().split()))

data.sort()

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

print(ans)


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

N, K = map(int, input().split())
fruit = input().split()
#print(fruit)
fruit = [int(x) for x in fruit]
#print(fruit)
fruit.sort()
#print(fruit)
print(sum(fruit[:K]))

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

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

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




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

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)

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

P.sort()

ans = 0

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

print(ans)

a,b = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
print(sum(c[0:b]))

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

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

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


from typing import List


def answer(n: int, k: int, p: List[int]) -> int:
    return sum(sorted(p)[:k])


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


def __starting_point():
    main()

__starting_point()

import numpy as np

n, k = list(map(int, input().split()))
fruits = np.array(input().split(),dtype=np.int64)
fruits.sort()
ans = 0
cnt = 0
for i in fruits:
    if(cnt < k):
        ans += i
        cnt += 1
print(ans)


#                               #
    # author : samars_diary #
    # 18-09-2020 │ 15:02:48 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    n,k=mii();b=0;a=sorted(lii())
    for i in range(k):
        b+=a[i]
    print(b)

for _ in range(1):
    solve()

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

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

print(ans)


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

import numpy as np
d = [int(x) for x in input().split(" ")]
K = d[1]

d = np.array([int(x) for x in input().split(" ")])

print((np.sort(d)[:K].sum()))



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

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

N, M = I()
A = l()
A.sort()
 
ans = 0
 
for i in range(M):
    ans += A[i]
 
print(ans)

N,K = map(int,input().split())
fruit = [int(i) for i in input().split()]

fruit.sort()
price = 0
for i in range(N) :
    if i>K-1 :
        break
    price += fruit[i]
    
print(price)

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

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

ans = 0

l = list()

for i in range(k):
    l.append(min(p))
    p.remove(min(p))    

ans = sum(l)

print(ans)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#import sympy
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

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

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, K = na()
p = na()
print((sum(sorted(p)[:K])))


from itertools import accumulate

N, K = map(int, input().split())
P = [0] + list(accumulate(sorted(map(int, input().split()))))

print(P[K])

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

p = sorted(p)
val = sum( p[ :n[1]])

print(val)

foo = list(input().split())
K = int(foo[1])
P = sorted(map(int,list(input().split())))
i=0
total = int(0)
while i < K:
    total = total + int(P[i])
    i+=1
print(total)

import itertools
[N, K] = [int(i)  for i in input().split()]
price = [int(i)  for i in input().split()]
price.sort()
sum = 0
for i in range(K):
    sum += price[i]
print(sum)

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

ans = 0

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

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

print(ans)


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

prices.sort()

print(sum(prices[:K]))

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

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

for i in p:
    r = int(i)
    res_list.append(r)

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

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)

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)

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


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

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


I=lambda:map(int,input().split());_,k=I();print(sum(sorted(I())[:k]))

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

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 0

P = sorted(P)
res = sum(P[:k])

print(res)


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

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

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

ans = 0

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

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


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)

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)

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

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


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

#https://atcoder.jp/contests/abc171/tasks/abc171_b

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

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

d= 0
for a in range(k):
    d= d+ b[a]

print(d)


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

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

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

sp = sorted(p)

score = 0

for i in range(k):
    score += sp[i]

print(score)

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

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

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)

_,K=map(int,input().split());*P,=map(int,input().split());P.sort();print(sum(P[:K]))

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)

n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
result = 0
for data in range(k):
    result += l[data]
print(result)


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

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


N, K = map(int, input().split())
P = list(map(int, input().split()))
assert len(P) == N
# 1 <= K <= N <= 1000
P = sorted(P)
print(sum(P[:K]))

a, b = map(int, input().split())
N = sorted(list(map(int, input().split())))
print(sum(N[0:b]))

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

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

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

N, K = list(map(int, input().split()))
l = list(map(int, input().split()))
S = sorted(l)
sums = sum(S[:K])
print(sums)


n, k = map(int, input().split())
pp = list(map(int, input().split()))
sp = sorted(pp)
ans = sum(sp[:k])
print(ans)

numline=input().split(" ")
a=int(numline[0])
b=int(numline[1])

numline=input().split(" ")
numlis=[]
for i in range(a):
    numlis.append(int(numline[i]))

numlis.sort()

result=0
for i in range(b):
    result+=numlis[i]

print(result)

N,K=(int(x) for x in input().split())

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

ans=0
p.sort()

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

print(ans)

a,b = map(int,input().split())
s = list(map(int,input().split()))
w = []

for i in range(b):
    w.append(min(s))
    s.remove(min(s))

print(sum(w))

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


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

p.sort()

print(sum(p[:K]))

import numpy as np
N, K = map(int, input().split())
p = list(map(int, input().split()))

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

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

p.sort()

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

print(sum_p)

N,K = map(int,input().split())
p = list(map(int,input().split()))
sp = sorted(p)
goukei = 0

for i in range(K):
  goukei += sp[i]

print(goukei)

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

n = input().split()
p = input().split()

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

num = n[1]

total = p[0:num]
total_price =sum(total)


print(total_price)

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

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

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

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

n, need = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
ans = 0

for i in range(need):
    ans += li[i]
    
print(ans)

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


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

int_k=int(k)-1

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


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

p = sorted(p)

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


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