import sys
def order (p):
    return (sorted(p))         
def Mix_Juice (p, K):
    N = len (p)
    a = order (p)
    b = 0
    for i in range (0, K):
        b = b + a[i]
    return b
N,K = map(int, input().split())
p = list(map(int, input().split()))
Mix_Juice (p,K)