from sys import stdin

from collections import defaultdict as dd

from collections import deque as dq

import itertools as it

from math import sqrt, log, log2

from fractions import Fraction



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

nums = list(map(int, stdin.readline().split()))

nums.sort()

print((sum(nums[:k])))

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

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



print((sum(sorted(nums)[:k])))
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

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

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

-from sys import stdin -from collections import defaultdict as dd -from collections import deque as dq -import itertools as it -from math import sqrt, log, log2 -from fractions import Fraction - -nums = list(map(int, stdin.readline().split())) -nums.sort() -print((sum(nums[:k]))) +nums = list(map(int, input().split())) +print((sum(sorted(nums)[:k])))