#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<algorithm>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define ll long long 
#define mod 998244353
using namespace std;



int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;

    int n,k;
    cin>>n>>;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    long long sum = 0;
    for(int i=0;i<k;i++){
        sum+= arr[i];
    }
    cout<<sum<<endl;
    

}