mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    #A, B = [int(x) for x in raw_input().split()]
    n, k = [int(x) for x in raw_input().split()]
    
    arr = [int(x) for x in raw_input().split()]
    
    arr.sort()
    
    ans = sum(arr[0:k])
    
    print(ans)
        
    

main()