import sys





def resolve():

    readline = sys.stdin.readline



    N, K = list(map(int, readline().split()))

    P = [int(x) for x in readline().split()]



    P = sorted(P)



    print((sum(P[:K])))



resolve()

import sys





def resolve():

    readline = sys.stdin.readline



    N, K = list(map(int, readline().split()))

    P = sorted([int(x) for x in readline().split()])



    print((sum(P[:K])))



resolve()

import sys


def resolve():
    readline = sys.stdin.readline
    N, K = list(map(int, readline().split()))
    P = [int(x) for x in readline().split()]
    P = sorted(P)
    print((sum(P[:K])))


resolve()

import sys


def resolve():
    readline = sys.stdin.readline
    N, K = list(map(int, readline().split()))
    P = sorted([int(x) for x in readline().split()])
    print((sum(P[:K])))


resolve()

-    P = [int(x) for x in readline().split()] -    P = sorted(P) +    P = sorted([int(x) for x in readline().split()])