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 itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue


Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

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):
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,k = I2()
    a = Intl()
    a.sort()
    print(sum(a[:k]))

Solution (Python):

import sys

sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)










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

if __name__ == "__main__":
    run()

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

p.sort()

print(sum(p[:K]))

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    p = list(in_nn())
    ans = sum(sorted(p)[:K])
    print(ans)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

[N,K]=[int(i) for i in sys.stdin.readline().split()]

p=[int(j) for j in sys.stdin.readline().split()]

p.sort()

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

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

print(sum(p[:K]))

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n,k = m()

a = l()

a.sort()

ans = 0

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

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

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

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

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

print(sum(p[:K]))

Solution (Python):
import math  
from typing import Dict, List, Optional, Tuple, Union  


def main(N: int, K: int, p: List[int]):
    p.sort()
    print(sum(p[:K]))


if __name__ == "__main__":
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    main(N, K, p)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

p.sort()

print(sum(p[:k]))

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    N,K=mi()
    P=list(mi())
    P.sort()


    print(sum(P[:K]))


if __name__ == "__main__":
  main()

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

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

Ps.sort()

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

Solution (Python):

import sys


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

Solution (Python):
N, K = map(int, input().split())
P = sorted([int(_) for _ in 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):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
Ps = list(mapint())
Ps.sort()
print(sum(Ps[: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 = map(int, input().split())
ps = sorted(list(map(int, input().split())))

print(sum(ps[:K]))

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

C_sort = sorted(C)

print(sum(C_sort[:K]))

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

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

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





if __name__ == "__main__":
    main()

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

Solution (Python):
import heapq

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

heapq.heapify(p)

total = 0
for i in range(k):
    total += heapq.heappop(p)

print(total)

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,k,*p = map(int,read().split())

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

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

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

main()

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

Solution (Python):
import sys
import math
import itertools

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

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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):
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

print(sum(P[:K]))

Solution (Python):
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N,K = inpl()
pls = inpl()
pls.sort()
pls = pls[:K]
print(sum(pls))

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

Solution (Python):
N,K = map(int,input().split())
*P, = 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())
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 = sum(A[: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 = [int(i) for i in input().split()]
pl = [int(i) for i in input().split()]
pl.sort()
  
print(sum(pl[: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):
def resolve():
    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)
resolve()

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

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

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

Solution (Python):
def main():

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


if __name__ == '__main__':
    print(main())

Solution (Python):
import sys

sys.setrecursionlimit(1000000)

import bisect
import math
import collections
import heapq


def solve(N, K, ps):
    ps.sort()
    return sum(ps[:K])


if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))

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

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):
def main():
    n,k = tuple([int(t)for t in input().split()])

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

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

if __name__ == "__main__":
    main()

Solution (Python):
x,y=map(int,input().split())
s=sorted(list(map(int,input().split())))
print(sum(s[:y]))

Solution (Python):
import os
import sys
from io import BytesIO, IOBase


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



from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL(): return map(int, sys.stdin.readline().rstrip().split())
def RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))
def N(): return int(input())
def comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0
def perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0
def mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')





def main():
    n, k = RL()
    arr = RLL()
    arr.sort()
    print(sum(arr[:k]))


if __name__ == "__main__":
    main()

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

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


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


if __name__ == '__main__':
    main()

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

Solution (Python):
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
a.sort()
print(sum(a[:k]))

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N, K = [int(x) for x in input().strip().split()]
    P = sorted([int(x) for x in input().strip().split()])
    print(sum(P[:K]))


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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


def main():
	N, K = getlist()
	P = getlist()
	P = sorted(P)
	ans = 0
	for i in range(K):
		ans += P[i]

	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[:K]))

Solution (Python):
import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, k = na()
p = na()


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, *p = map(int, open(0).read().split())
p.sort()
ans = 0
for i in range(k):
    ans += p[i]
print(ans)

Solution (Python):
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))


def solve():
    return

def main():
    n,k = get_tuple()
    ls = get_list()
    ls.sort()
    ans = 0
    for i in range(k):
        ans += ls[i]
    print(ans)


TestCases = False

if TestCases:
    for i in range(get_int()):
        main()
else:
    main()

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



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


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

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

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

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

Solution (Python):
import os
import sys
from io import BytesIO, IOBase

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 list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7


Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

n,k = Ri()
a = Ri()
a.sort()


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

print(ans)

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

Ps.sort()

print(sum(Ps[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 = sorted(p)
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):
"""
~~ Author : Bhaskar
~~ Dated : 10~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")
input = lambda : sys.stdin.readline()

def solve():
    n, k = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    a.sort()
    s = 0
    for i in range(k):
        s += a[i]
    print(s)


if __name__ == "__main__":
    try:
        sys.stdin = open('input.txt','r')
        sys.stdout = open('output.txt','w')
    except:
       pass
    solve()

Solution (Python):
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 
N, K = rrm()
a = rrm()
a = sorted(a)
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 = 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())
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()))
ans = 0
p.sort()
for i in range(k):
    ans += p[i]
print(ans)

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

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

print(sum(a[:k]))

Solution (Python):
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math


MOD = 10 ** 9 + 7



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

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,k =MAP()

a = LIST()

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

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    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)
    
    
    

if __name__ == '__main__':
    main()