Problem:
 Score : 200 points    Problem Statement A shop sells N kinds of fruits, Fruit 1, \ldots, N , at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)  Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.      Constraints  1 \leq K \leq N \leq 1000  1 \leq p_i \leq 1000  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  K  p_1  p_2  \ldots  p_N       Output Print an integer representing the minimum possible total price of fruits.        Sample Input 1 5 3
50 100 80 120 80      Sample Output 1 210  This shop sells Fruit 1 , 2 , 3 , 4 , and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.  The minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1 , 3 , and 5 .       Sample Input 2 1 1
1000      Sample Output 2 1000

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

Solution (Python):

import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def solve(N: int, K: int, p: "List[int]"):
    p.sort()
    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.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 = 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):
def examA():
    S = SI()
    if S in alphabet:
        ans = "a"
    else:
        ans = "A"
    print(ans)
    return

def examB():
    N, K = LI()
    P = LI()
    P.sort()
    ans = sum(P[:K])
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, K = LI()
    p = sorted(LI())
    ans = sum(p[:K])
    print(ans)


main()

Solution (Python):









def solve():
    N, K = map(int, input().split())
    ps = list(map(int, input().split()))

    ps.sort()
    return sum(ps[:K])


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

Solution (Python):
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

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

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

print(sum(P[:K]))

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



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

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)
from string import ascii_lowercase

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))
a.sort()

print(sum(a[:k]))

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

if __name__ == '__main__':
    main()

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

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

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

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

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()

print(sum(a[:k]))

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

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

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

p = sorted(p)
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):
import sys

import math
import collections

import bisect
import itertools
import fractions

import copy

import decimal

import queue



sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7


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



def main():
    n, k = ns()
    p = na()

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
P = rl()

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

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())
print(sum(sorted([int(a) for a in input().split()])[:K]))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
P = LIST()
P.sort()
print(sum(P[:K]))

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

def solve():
    N, K = map(int, readline().split())
    P = list(map(int, readline().split()))

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

solve()

Solution (Python):
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, K = mi()
    p = list(mi())
    p.sort()
    print(sum(p[:K]))

if __name__ == '__main__':
    main()

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

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

    p.sort()

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

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n, k = 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):
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  
from fractions import gcd
import sys  

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

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

import math








input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 998244353

def solve():
    n, k = getList()
    nums = getList()

    print(sum(sorted(nums)[:k]))
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    
    solve()

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N,K = LMIIS()
    P = LMIIS()
    P.sort()
    print(sum(P[:K]))
    
main()

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

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

Solution (Python):


import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
import bisect
from queue import PriorityQueue
import itertools
from itertools import accumulate
from copy import deepcopy
from collections import Counter
import heapq
import random
import time
import os
import sys
import datetime
from functools import lru_cache
from functools import reduce
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
alphabet="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):
    if b:print("yes")
    else:print("no")
def Yn(b):
    if b:print("Yes")
    else:print("No")
def YN(b):
    if b:print("YES")
    else:print("NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(bbool,ret1,ret2):
    if bbool:return ret1
    else:return  ret2
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def pm(x):
    return x//abs(x)
def inputintlist(): 
    return list(map(int,input().split()))
def inputfloatlist(): 
    return list(map(float,input().split()))
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow






n,k=inputintlist()
P=inputintlist()
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):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = map(int, readline().split())
    a = list(map(int, readline().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):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
print(sum(a[: K]))

Solution (Python):

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

Solution (Python):


import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, k = map(int, sys.stdin.readline().split())
	p = list(map(int, sys.stdin.readline().split()))
	p.sort()
	print(sum(p[:k]))
	


main()

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

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

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A = sorted(A)
    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 = [int(i) for i in input().split()]
a.sort()
print(sum(a[:k]))

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

Solution (Python):
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
p = readInts()

p.sort()

print(sum(p[:k]))

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

L = sorted(L)
print(sum(L[:K]))

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    P = il()
    P.sort()
    print(sum(P[: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):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N,K=mis()
    p=lmis()
    p.sort()
    print(sum(p[:K]))


main()

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

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

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

print(sum(p[:K]))

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

    A.sort()

    print(sum(A[:K]))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): 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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]





N, M = mi()
A = li()

A = sorted(A)

print(sum(A[:M]))