#include <bits/stdc++.h>
  #pragma GCC target ("avx2")
  #pragma GCC optimization ("O3")
  #pragma GCC optimization ("unroll-loops")
  using ll = long long;
  using ld = long double;
  #define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
  #define br cout<< "\n";
  #define endl "\n"
  #define vi vector<int>
  #define vii vector<ll>
  #define pll pair<ll,ll>
  #define pii pair<int,int>
  #define pcl pair<char,ll>
  #define pb push_back
  #define eb emplace_back
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  #define all(v) begin(v),end(v)
  #define minv(a) *min_element(all(a))
  #define maxv(a) *max_element(all(a))
  #define outputv(a) for(auto i:a) cout<<i<<" ";br;
  #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  #define outputvp(a) for(auto j:a) {cout<<j.first<<" " << j.second << ",",br;}
  using namespace std;

  const ll mod = 1000000007;
  const ll inf = 1000000000000000000;
  const ll rk = 256;
  const ld PI = 3.141592653589793;
  
  // ll isPrime[10000001];
  ll power( ll base, ll power, ll mod);
  ll bc(ll n, ll k);
  ll nxt();
  void seive();
  void primeDivisors(map<ll,ll> &mapi, ll n);
  void inout();

  bool check(ll n){
    if(n <=1) return false;
    if(n == 2 || n == 3) return true;

    if(n%2 ==0 || n%3 ==0) return false;

    for(int i=5; i*i <= n; i+=6){
      if(n%i == 0 || n%(i+2) ==0) return false;
    }
    return true;
  }

  
  void solve(){
   
   ll n=nxt(), k =nxt();
   vii a(n); rep(i,0,n) cin >> a[i];
   sort(all(a));
   ll ans = 0;
   rep(i,0,k) ans+=a[i];
   cout << ans << endl;


}

  int main(){
     FastIO
    inout();
    solve();
  return 0;
}

  void inout(){
      // seive();
      #ifndef ONLINE_JUDGE
          // for getting input from input.txt
          freopen("/home/logan/contest/ongoing/input.txt", "r", stdin);
          // for writing output to output.txt
          freopen("/home/logan/contest/ongoing/output.txt", "w", stdout);
      #endif
  }
 
  ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
  }



  // void primeDivisors(map<ll,ll> &mapi, ll n){
  //   while(n > 1){
  //     if(isPrime[n] == -1){
  //       mapi[n]+Codeforces Subsequences codeforces=1;
  //       break;
  //     }
  //     else{
  //       mapi[isPrime[n]]+=1;
  //       n/=isPrime[n]; 
  //     }
  //   }
  // }

// void seive(){
//   ll maxn = 10000001;
//   isPrime[0] = 0; isPrime[1] = 0;
//   rep(i,2,maxn) isPrime[i] = -1;
//   for(int i=2; i*i < maxn; i++){
//     if(isPrime[i] == -1){
//       for(int j=i*i; j < maxn; j+=i){
//         if(isPrime[j] == -1){
//           isPrime[j] = i;
//         }
//       } 
//     }
//   }

// }

 ll power( ll base, ll power, ll mod){
    ll res = 1;
    while( power ){
      if(power%2) res= (res*base)%mod, power--;
      else base= (base * base)%mod, power/=2;
    }

    return res;
  }

  ll bc(ll n, ll k) 
    { 
      ll C[k+1]; 
      memset(C, 0, sizeof(C)); 
  
      C[0] = 1; 
  
      for (ll i = 1; i <= n; i++) 
      { 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
      } 
      return C[k]; 
    } 

Measured memory_bytes: 3612