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

p.sort()

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

Solution (Python):
def main():
    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    P.sort()
    ans = sum(P[: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[:K]))

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


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

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

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

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


if __name__ == "__main__":
    main()

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

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

import numpy as np

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

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

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

print(sum)

Solution (Python):















mod = int(1e9+7)

INF = 1<<50

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

def main():
    n,k = readInt()
    p = readInt()
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)
    return

if __name__=='__main__':
    main()

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):
import sys
input = sys.stdin.readline

N,K=(int(x) for x in input().rstrip('\n').split())
As = sorted([int(x) for x in input().rstrip('\n').split()])
print(sum(As[: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):
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    prices = [int(item) for item in input().split()]

    prices.sort()

    res = 0
    for i in range(K):
        res += prices[i]

    print(res)


if __name__ == "__main__":
    resolve()

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

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

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

new = sorted(P)

ans = 0

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

p.sort()

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

print(total_min)

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

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

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 k in range(K):
  ans += P[k]
print(ans)

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

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

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

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

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

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

Solution (Python):
def main():
    N,K=map(int,input().split())
    p = sorted([int(_) for _ in input().split()])
    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):
a,b=map(int,input().split())
c=list(map(int,input().split()))
c=sorted(c)
print(sum(c[0:b]))

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

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    p = read_ints()
    p.sort()
    return sum(p[:K])


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

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

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

Solution (Python):
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:(input())
ips=lambda:input().split()

"""========main code==============="""
a,b=ml()
n=ll()
n.sort()
print(sum(n[:b]))

Solution (Python):
n,k=map(int,input().split())
hoge=list(map(int,input().split()))
hoge.sort()
print(sum(hoge[: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()
if k<n:
  print(sum(P[:k]))
else:
  print(sum(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):
import sys
input = sys.stdin.readline

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

a = p[0:K]

print(sum(a))

Solution (Python):
def main():
    N, K = map(int, input().split())
    P = [int(p) for p in input().split()]
    P.sort()
    ans = sum(P[:K])
    print(ans)

if __name__ == "__main__":
    main()

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

    p_sort = sorted(p)

    print(sum(p_sort[:K]))


if __name__ == '__main__':
    main()

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

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


a_list.sort()

sumn=sum(a_list[:K])


print(sumn)

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

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

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




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

print(sum(p[:K]))

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    p.sort()

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

Solution (Python):
a,b=map(int,input().split())
c=list(map(int,input().split()))
c=sorted(c)
s=0
for i in range(b):
  s=s+c[i]
print(s)

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

Solution (Python):
import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools

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

Solution (Python):
import math



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

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


if __name__ == "__main__":
    main()

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

Solution (Python):
from collections import *
from math import *

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

Solution (Python):
n, num_buy = [int(i) for i in input().split()]
price = [int(i) for i in input().split()]

price = sorted(price)

print(sum(price[:num_buy]))

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()]
print(sum(sorted([int(i) for i in input().split()])[: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(' '))
nedan = sorted(list(map(int, input().split(' '))))

print(sum(nedan[:K]))

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

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

print(ans)

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

Solution (Python):
import sys

n, k, *ppp = map(int, sys.stdin.buffer.read().split())
ppp.sort()
print(sum(ppp[: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()))
P1=sorted(P)
ans=0
for i in range(K):
    ans+=P1[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())
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()
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):

def main():
    import sys
    imput = sys.stdin.readline
    
    
    
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

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

    
if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
N, K = list(map(int, sys.stdin.readline().rstrip().split())) 
P = list(map(int, sys.stdin.readline().rstrip().split())) 

P = sorted(P)
ans = sum(P[:K])
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())

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

print(sum(P[:k]))

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

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

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

    p.sort()

    print(sum(p[:K]))


if __name__ == "__main__":
    main()

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

print(a)

Solution (Python):
import sys

def input(): return sys.stdin.readline().strip()
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 INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N, K = MAP()
A = LIST()

A.sort()
ans = sum(A[:K])
print(ans)

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools










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

p.sort()

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

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

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

p.sort()

print(sum(p[:K]))

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,k = MI()
p = RI()

p.sort()

q = p[:k]

ans = sum(q)

print(ans)

Solution (Python):
import sys
import math
from collections import defaultdict, deque
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))
  
n,m=rm()
a=rl()
a.sort()
print(sum(a[:m]))

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

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

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

Solution (Python):

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

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

print(res)

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

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

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

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

Solution (Python):


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

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

Solution (Python):
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n,k = mi()
    p = li()
    p = list(sorted(p))
    ans = 0
    for i in range(k):
        ans+=p[i]
    print(ans)

main()

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

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.read
def main():
    n, k, *p = map(int, read().split())  
    p.sort()
    r = sum(p[:k])
    print(r)

if __name__ == '__main__':
    main()

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

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

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

p.sort()

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

Solution (Python):
N, K = map(int, input().split())
N_list = sorted(list(map(int, input().split())))
print(sum(N_list[: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[0:k]))

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

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

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

Solution (Python):
N, K = map(int,input().split())
p =list(map(int, input().split()))
p = sorted(p)
ans = 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()
minprice = sum(p[:k])

print(minprice)

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

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

Solution (Python):
import sys
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):
N, K = map(int, input().split(" "))
p = [int(x) for x in input().split(" ")]
print(sum(sorted(p)[:K]))

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

result = 0

P_soreted = sorted(P)
for i in range(K):
    result += P_soreted[i]
print(result)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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):
import numpy as np

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

p = sorted(p)

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

print(int(ans))

Solution (Python):




import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

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

Solution (Python):

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

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

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

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

Solution (Python):

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

p = sorted(p)

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

Solution (Python):
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

n, k = multi_int_input()

prices = list_input()

prices.sort()

s = 0
for i in range(k):
    s+=prices[i]

print(s)

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

count=0
for i in range(k):
  count+=pp[i]
print(count)

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):
if __name__ == '__main__':
    b, c = map(int, input().split())
    a = [int(i) for i in input().split()]
    ans = 0
    a.sort()
    for i in range(c):
        ans+=a[i]
    print(ans)

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

Solution (Python):


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

p = sorted(p)

ans = sum(p[:k])

print(ans)

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

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

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

p = sorted(p)

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

Solution (Python):

"""
@author: H_Hoshigi
"""
def main():
    N, K = map(int, input().split())
    p_lsit = list(map(int, input().split()))

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

if __name__ == "__main__":
    main()

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

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

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

print(sum(p_sort[:K]))