#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int p[n+5]={0};
    for(int i=1;i<=n;i++)scanf("%d",&p[i]);
    sort(p+1,p+n+1);
    int sum=0;
    for(int i=1;i<=k;i++)sum=sum+p[i];
    printf("%d",sum);
    return 0;
}
