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

Solution (Python):



import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    p = sorted(i2nn())
    print(sum(p[:K]))
    return

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

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

ls = sorted(ls)

print(sum(ls[: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())
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()

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

print( cost )

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

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

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

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

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

Solution (Python):
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    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)

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= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

def resolve():
    N,K=pin()
    P=sorted(lispin())[:K]
    print(sum(P))


resolve()

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

p_L = list(sorted(p_L))
print(sum(p_L[:k]))

Solution (Python):
import math
import fractions
import collections
import itertools
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 = list(map(int, input().split()))
p_list.sort()
ans = 0

for i in range(k):
    ans += p_list[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())
p = [int(i) for i in input().split()]

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

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

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

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

a.sort()

price = 0
for i in range(K):
    price+=a[i]

print(price)

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

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

Solution (Python):
N,K = (int(x) for x in input().split())
p = list(map(int, input().strip().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):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

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

    return

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

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

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

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

val = sum(sorted(ps)[:k])

print(val)

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

print(ans)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
A = readInts()
mi = float('inf')
A = sorted(A)

print(sum(A[:k]))

Solution (Python):
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


n, k = map(int, input().split())
p = readints()
pp = sorted(p)

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

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

p.sort()
sm=0
for i in range(k):
  sm+=p[i]
print(sm)

Solution (Python):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
counta = 0
result = 0
for i in p:
    if counta == k:
        break
    counta+=1
    result += i
print(result)

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

n,k = LI()
p = LI()

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

Solution (Python):
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline



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

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

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

print(ans)

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

Ps.sort()

print(sum(Ps[:K]))

Solution (Python):
def solve(n, k, p_list):
    p_list_s = list(sorted(p_list))
    return sum(p_list_s[:k])


def main():
    n, k = map(int, input().split())
    p_list = list(map(int, input().split()))
    res = solve(n, k, p_list)
    print(res)


def test():
    assert solve(5, 3, [50, 100, 80, 120, 80]) == 210
    assert solve(1, 1, [1000]) == 1000


if __name__ == "__main__":
    test()
    main()

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

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

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

A.sort()
Amin = A[:k]
print(sum(Amin))

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

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

p_list = sorted(p_list)

print(sum(p_list[: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.sort()
print(sum(P[:K]))

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

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

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

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

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

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

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

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

print(sum(s[:k]))

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N, K = mulinputs()
    ps = list(mulinputs())

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

Solution (Python):
import sys

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

p_list.sort(reverse=False)


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

print(cost)

Solution (Python):
a,b=map(int,input().split())
arr=list(map(int,input().split()))
arr.sort()
ans=0
for i in range(b):
    ans+=arr[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()))

P.sort()

print(sum(P[:k]))

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

Solution (Python):
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

n, k = MAP()
p = LIST()
p = sorted(p)
print(sum(p[:k]))

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

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

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

    P.sort()
    print(sum(P[:k]))
    return 

if __name__ == "__main__":
    main()

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

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

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

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

p.sort()

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

Solution (Python):
def main():
    N, K = map(int, input().split())
    p = sorted(map(int, input().split()))
    return sum(p[:K])
    
if __name__ == '__main__':
    print(main())

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

Solution (Python):
import sys

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

P.sort()

print(sum(P[:K]))

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

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

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, K = input_number_list()
    p = input_number_list()
    p.sort()
    ans = 0
    for i in range(K):
        ans += p[i]
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()



def solve():
    n,k = invr()
    a = inlt()
    a.sort()
    print(sum(a[:k]))
            


 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 

def counter(a):
    q = [0] * (max(a) + 1)
    for i in range(len(a)):
        q[a[i]] = q[a[i]] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)


        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

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

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

p.sort()

p=p[:k]

print(sum(p))

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


plist.sort()

ans = 0

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

print(ans)

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

Solution (Python):
import sys











stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

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

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

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

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

P.sort()

ans=sum(P[0:K])

print(ans)

Solution (Python):
n, k = map(int, input().split())
t = list(map(int, input().strip().split()))
t.sort()
print(sum(t[0: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 = 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):
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()
mm = P[:K]
print(sum(mm))

Solution (Python):
N, K = map(int, input().split())
prices = list(map(int, input().split()))
prices.sort()
print(sum(prices[: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)[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 bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, k = M()
p = LI()
p.sort()
ans = 0
for i in range(k):
    ans += p[i]
print(ans)

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

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

print(sum(li[0: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())
arr = [int(x) for x in input().split()]

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

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

ps = sorted(ps)

print(sum(ps[:k]))

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

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

p.sort()

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

print(total)

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

p.sort()

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

Solution (Python):
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
p = li()

p.sort()

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

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

result = 0

for i in range(K):
    result += Ps[i]

print(result)

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

n, k, *lst = map(int, read().split())
lst.sort()
print(sum(lst[:k]))

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

Solution (Python):


import sys; import math; from collections import *


def get_ints(): return map(int, input().split())
def get_list(): return list(get_ints())
def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9+7); SEXYMOD = 998244353; MAXN = int(1e5)




n, k = get_ints()
li = get_list()
print(sum(sorted(li)[:k]))


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

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 io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

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

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

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

resolve()

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

p.sort()

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