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

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

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

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    p=LIST()
    p=sorted(p)
    print(sum(p[0:k]))
if __name__ == '__main__':
    do()

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 = [int(i) for i in input().split()]
p.sort()

print(sum(p[: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):
from collections import Counter, defaultdict


_,k = list(map(int,input().split()))
lst = list(map(int,input().split()))

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

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

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

Solution (Python):
import sys

stdin = sys.stdin


def ni(): return int(ns())


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


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  


N, K = na()

p_array = na()

p_array.sort()

print(sum(p_array[: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 heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

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

Solution (Python):

import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a = [int(item) for item 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):
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())
al = list(map(int, input().split()))
al.sort()
print(sum(al[: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())
line = list(map(int, input().split()))
line.sort()
sum = 0
for i in range(k):
  sum += line[i]
print(sum)

Solution (Python):
n,k,*p = map(int,open(0).read().split())

p.sort()

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

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

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    print(sum(A[:K]))

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys


buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, P):
    P.sort()
    return sum(P[:K])


def main():
    N, K = read_int_n()
    P = read_int_n()
    print(slv(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):
def main():
    n, k = [int(x) for x in input().split()]
    l = [int(x) for x in input().split()]
    l.sort()
    print(sum(l[:k]))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
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().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
ans = 0
A.sort()
for i in range(K):
    ans += A[i]
print(ans)

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

p=sorted(p)

print(sum(p[:k]))

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction

sys.setrecursionlimit(int(pow(10,6)))


mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]



n,k=l()
A=l()
A.sort()
print(sum(A[: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):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]



def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res



def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    N, K = NMI()
    A = NLI()
    A.sort()
    print(sum(A[:K]))


if __name__ == "__main__":
    main()

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

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

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

print(ans)

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N, K = ri_()
p = sorted(ri_())
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(j) for j in input().split()]
l = [int(j) for j in input().split()]
l.sort()
print(sum(l[:k]))

Solution (Python):

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


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


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


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


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


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


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


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


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


sys.setrecursionlimit(1000000)


def main():
    N, K = LI()
    A = LI()
    A.sort()

    print(sum(A[:K]))


main()

Solution (Python):
import sys
import math
def II():
	return int(sys.stdin.readline())

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

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

def SI():
	return sys.stdin.readline().strip()
n,k = MI()
a = sorted(LI())
print(sum(a[:k]))

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

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

print(res)

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


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

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

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

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

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

P.sort()

ans = sum(P[:k])
print(ans)

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

print(sum(Ps[:K]))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

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

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):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=mp()
p=sorted(lmp())
print(sum(p[:k]))

Solution (Python):


import sys

class BMixJuice:
    def solve(self, tc=0):
        n, k = [int(_) for _ in input().split()]
        p = [int(_) for _ in input().split()]
        p.sort()
        print(sum(p[:k]))


solver = BMixJuice()
input = sys.stdin.readline

solver.solve()

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(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):
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()
print(sum(P[:K]))

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


def read():
    N, K = list(map(int, input().strip().split()))
    P = list(map(int, input().strip().split()))
    return N, K, P


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


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    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)

if __name__ == '__main__':
    main()

Solution (Python):
n,k,*a=map(int,open(0).read().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 main():
    N, K = list(map(int, input().split()))
    P = list(map(int, input().split()))
    P.sort()

    return sum(P[:K])

print(main())

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

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

Solution (Python):

def resolve():
    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))

    print(sum(A[:K]))

if __name__ == "__main__":
    resolve()

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

Solution (Python):



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


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

n,k = mp()
p = lmp()
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 main():
    
    n,k=map(int, input().split())
    A=[int(i) for i in input().split()]
    A.sort()
    print(sum(A[:k]))

if __name__ == '__main__':
    main()

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()
  l.sort()

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


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

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

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

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(_) for _ in input().split()]
p = [int(_) for _ in input().split()]
p.sort()
print(sum(p[:K]))

Solution (Python):
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18


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, *p = map(int, open(0).read().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 = map(int, input().split())
P = [int(p) for p 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()
print(sum(p[:K]))

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n, k = LI()
	p_list = LI()
	p_list.sort()
	print(sum(p_list[:k]))


if __name__ == '__main__':
    main()

Solution (Python):

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

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

print(sum(p[:k]))

Solution (Python):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n, k = inpl()
p = sorted(inpl())
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 = [int(_) for _ in input().split()]
p = sorted([int(_) for _ in 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):
N, K = map(int, input().split())
P = sorted(list(map(int, input().split())))
ans = sum(P[:K])
print(ans)

Solution (Python):

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

Solution (Python):

import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n,k = ip()
x = ip()
x.sort()
print(sum(x[:k]))

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

def main():
    N, K = map(int, readline().rstrip().split())
    P = list(map(int, readline().rstrip().split()))
    P.sort()

    print(sum(P[:K]))
    
if __name__ == '__main__':
    main()

Solution (Python):
R = lambda: map(int, raw_input().split())
n, k = R()
print sum(sorted(R())[: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):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
p = LI()
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 = [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()
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(sorted(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[:k]))

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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

Solution (Python):
import sys 
input = lambda:sys.stdin.readline().strip()
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)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, K = ZZ()
    P = sorted(ZZ())
    print(sum(P[:K]))

    return

if __name__ == '__main__':
    main()

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, *p = map(int, open(0).read().split())
print(sum(sorted(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[:K]))

Solution (Python):
from math import *
from bisect import bisect_left

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

def cins(): 
    return input.split()

def cino(test=False): 
    if not test:
        return int(input())
    else: 
        return input()

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

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

def printlist(l): 
    for i in l:
        print(i,end=" ")

def bs(arr, l, r, x): 
    while l <= r: 
        mid = l + (r - l) // 2; 
        if arr[mid] == x: 
            return mid 
        elif arr[mid] < x: 
            l = mid + 1
        else: 
            r = mid - 1
    return -1


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

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

Solution (Python):


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

p.sort()

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

print(ans)

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

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

pl.sort()

ans = sum(pl[: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


def solve(N: int, K: int, p: "List[int]"):
    p = sorted(p)
    result = 0
    for k in range(K):
        result += p[k]
    print(result)
    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()