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

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

list.sort()

ans = 0
for i in range(k):
    ans += list[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 = int(0)
for i in range(min(n,k)):
    ans += p[i]

print(ans)

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

print(sum(ans))

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

Solution (Python):
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().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 = (int(x) for x in input().split())
p = list(map(int, input().split()))

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

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):
nk = input('')
n = int(nk.split(' ')[0])
k = int(nk.split(' ')[1])

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

plist.sort()

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

print(m)

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

pi.sort()

ans = 0

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

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res


N,K=LI()
PS=LI()

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

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

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

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

Solution (Python):



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

PList.sort()
PList=PList[:K]
print(sum(PList))

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

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

p.sort()

sum = 0
for i in range(NK[1]):
    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 = 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 = list(map(int,input().split()))

p_list_sorted = sorted(p_list)

print(sum(p_list_sorted[:k]))

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n,k = imap()
p = sorted(iarr())

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

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

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

print(sum(p[:k]))

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

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

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

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

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

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

Solution (Python):
def ya():
  print("Yes")
  return
def na():
  print("No")
  return


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

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

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

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

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

Solution (Python):

import sys


def solve(N: int, K: int, p: "List[int]"):
    p = sorted(p)
    print(sum(p[:K]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    p = [int(next(tokens)) for _ in range(N)]  
    solve(N, K, p)

if __name__ == '__main__':
    main()

Solution (Python):

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

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

out = 0
for i in range(k):
    minp = min(ps)
    out += minp
    ps.remove(minp)
print(out)

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


price.sort()

ans=sum(price[i] for i in range(K))
print(ans)

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

sp = sorted(p)
ans = 0

for i in range(int(k)):
    ans += sp[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()
print(sum(p[:k]))

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

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



values = sorted(p)

print(sum(values[:K]))

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

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

Solution (Python):

import sys
input = sys.stdin.readline



def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp


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


def nCr(n, k): 
    if(k > n - k): 
        k = n - k 
    res = 1
    for i in range(k): 
        res = res * (n - i) 
        res = res / (i + 1) 
    return int(res) 


def upper_bound(a, x, lo=0):
    hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo


def primefs(n):
    
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    
    
    return primes


def power(x, y, p): 
    res = 1
    x = x % p  
    if (x == 0) : 
        return 0
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1      
        x = (x * x) % p 
    return res 


def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b









def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];
    
    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;




def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x


def sieve(n): 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime


MAXN = int(1e6 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    




def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    
    


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

def str_array():
    return input().strip().split();


MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');



n, k = int_array(); a = sorted(int_array());
print(sum(a[:k]));

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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

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

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

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

print(ans)

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

p.sort()

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

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

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

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 array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

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

p = sorted(p)

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

print(res)

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

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


if __name__ == "__main__":
    main()

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

flist.sort()

print(sum(flist[: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):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd




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

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

Solution (Python):
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd 
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) 


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

Solution (Python):
def solve():
    print(sum(sorted(p)[: K]))

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

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):
def solve():
    ans = 0
    for i in range(k):
        ans += arr[i]
    return ans



if __name__ == '__main__':
    n, k = map(int, input().split())
    arr = sorted(list(map(int, input().split())))
    print(solve())

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=(int(i) for i in input().split())
l=sorted([int(i) for i in input().split()])
s=sum(l[:k])
print(s)

Solution (Python):



def minimize(k, ps):
    qs = sorted(ps)
    return sum(qs[:k])


def main():
    n, k = (int(z) for z in input().split())
    ps = [int(p) for p in input().split()]
    res = minimize(k, ps)
    print(res)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


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


def F(): return float(input())


def ST(): return input().replace('\n', '')


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


if __name__ == '__main__':
    main()

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

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


def main(input, print):
    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(sys.stdin.readline, print)

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

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

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

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

Solution (Python):
import sys
import math
n,k=map(int,input().split())
a=list(map(int,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[:k]))

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

Solution (Python):
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,k = NextInts()
print(sum(sorted(NextIntList())[:k]))

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

if __name__ == '__main__':
    main()

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

P.sort()

print(sum(P[:K]))

Solution (Python):
n,k = map(int,input().split())
p = list(map(int,input().split()))
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.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):
from math import *

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

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

print(ans)

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

slis = sorted(lis)

ans = 0

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

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

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

print(sum(P[:K]))

Solution (Python):


import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N, K = next(it), next(it)
    P = list(it)
    P.sort()
    print(sum(P[:K]))

if __name__ == "__main__":
    resolve()

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

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

cnt = 0
for i in range(k):
    cnt += l[i]
print(cnt)

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

P=sorted(P)
ans=sum(P[:K])
print(ans)

Solution (Python):
import numpy as np

N, K = list(map(int, input().split()))
fruits = sorted(list(map(int, input().split())))

print(np.sum(fruits[:K]))

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

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

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

Solution (Python):

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

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

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
s = 0
for i in range(m):
    s += a[i]
print(s)

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def main():
    n, k = MII()
    pp = MII()
    pp.sort()
    print(sum(pp[:k]))

if __name__ == '__main__':
    main()

Solution (Python):

"""
Created on Sun Jun 21 21:01:51 2020

@author: NEC-PCuser
"""

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

p = p[:k]

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

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

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

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


print(sum(L[:K]))

Solution (Python):

import sys

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


def main():
    n,k = na()
    ps = na()
    ps.sort()
    print(sum(ps[:k]))
    return


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

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

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

main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Solution (Python):
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
p = inpl()
print(sum(sorted(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):
n,k=map(int, input().split(' '))
l=list(map(int, input().split(' ')))
s=0
for i in range(k):
    m=min(l)
    s+=m
    l.pop(l.index(m))
print(s)

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


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)]  
    print(solve(N, K, p))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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

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

Solution (Python):
import sys
import time




import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n,k=rl()
p=rl()
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())

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

l.sort()

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

print(sum(p[:k]))

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

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

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

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

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

ps.sort()

ms = sum(ps[:k])
print(ms)

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

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

Solution (Python):
from sys import stdin
input = 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)