import sys



sys.setrecursionlimit(10 ** 8)



input = sys.stdin.readline





def main():

    N, K = [int(x) for x in input().split()]

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



    P.sort()



    ans = 0

    for i in range(K):

        ans += P[i]



    print(ans)

    

    

    



if __name__ == '__main__':

    main()



import sys



sys.setrecursionlimit(10 ** 8)



input = sys.stdin.readline





def main():

    N, K = [int(x) for x in input().split()]

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

    P.sort()



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











if __name__ == '__main__':

    main()



import sys

sys.setrecursionlimit(10**8)
input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    P.sort()
    ans = 0
    for i in range(K):
        ans += P[i]
    print(ans)


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(10**8)
input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    P.sort()
    print((sum(P[:K])))


if __name__ == "__main__":
    main()

-    ans = 0 -    for i in range(K): -        ans += P[i] -    print(ans) +    print((sum(P[:K])))