import sys

import itertools

sys.setrecursionlimit(1000000000)

from heapq import heapify,heappop,heappush,heappushpop

import math

import collections

import copy





if __name__ == "__main__":

    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)
import sys

import itertools

sys.setrecursionlimit(1000000000)

from heapq import heapify,heappop,heappush,heappushpop

import math

import collections

import copy



def main():

    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)

 

if __name__ == "__main__":

    main()
import sys
import itertools

sys.setrecursionlimit(1000000000)
from heapq import heapify, heappop, heappush, heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    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)

import sys
import itertools

sys.setrecursionlimit(1000000000)
from heapq import heapify, heappop, heappush, heappushpop
import math
import collections
import copy


def main():
    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)


if __name__ == "__main__":
    main()

-if __name__ == "__main__": + +def main(): + + +if __name__ == "__main__": +    main()