import sys



readline = sys.stdin.readline

MOD = 10 ** 9 + 7

INF = float('INF')

sys.setrecursionlimit(10 ** 5)





def main():

    n, k = list(map(int, readline().split()))

    a = list(map(int, readline().split()))

    a.sort()



    print((sum(a[:k])))





if __name__ == '__main__':

    main()

n, k = list(map(int, input().split()))

a = list(map(int, input().split()))



a.sort()

ans = sum(a[:k])

print(ans)
import sys

readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)


def main():
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    print((sum(a[:k])))


if __name__ == "__main__":
    main()

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
ans = sum(a[:k])
print(ans)

-import sys - -readline = sys.stdin.readline -MOD = 10**9 + 7 -INF = float("INF") -sys.setrecursionlimit(10**5) - - -def main(): -    n, k = list(map(int, readline().split())) -    a = list(map(int, readline().split())) -    a.sort() -    print((sum(a[:k]))) - - -if __name__ == "__main__": -    main() +n, k = list(map(int, input().split())) +a = list(map(int, input().split())) +a.sort() +ans = sum(a[:k]) +print(ans)