#include <bits/stdc++.h>
using namespace std;
//using namespace std::chrono;

typedef unsigned short int      us;   //2  0 to 65,5357
typedef unsigned int            ui;    //4  0 to 4,294,967,295
typedef unsigned long long int  ull;  //8  0 to 18,446,744,073,709,551,615
typedef short int               si;    //2  -32,768 to 32,767
typedef int                     in;    //4  -2,147,483,648 to 2,147,483,647
typedef long long int           lli;   //8   -9,223,372,036,854,775,807 to 9,223,372,036,854,775,806
typedef char                    ch;    //1
typedef float                   fl;    //4   +/-3.4e +/-38 (~7 digits)
typedef double                  dou;    //8   +/-1.7e +/-308 (~15 digits)

#define tests ull T_;cin>>T_;rei(T,1,T_)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define v(x) std::vector<x>
#define v2(x,name,r,c) std::vector<std::vector<x>> name(r,std::vector<x>(c))
#define p(x,y) std::pair<x,y>
#define s(x) std::set<x>
#define m(x,y) std::map<x,y>
#define um(x,y) std::unordered_map<x,y>
#define ub_i(v,val) std::upper_bound(v.begin(), v.end(), val) - v.begin()
#define ub_in(v,n,val) std::upper_bound(v.begin(), v.begin()+n, val) - v.begin()
#define lb_i(v,val) std::lower_bound(v.begin(), v.end(), val) - v.begin()
#define lb_in(v,n,val) std::lower_bound(v.begin(), v.begin()+n, val) - v.begin()
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define rei(i,a,n) for(lli i=a;i<=n;++i)
#define reit(it,a) for(auto it=a.begin();it!=a.end();++it)
#define red(i,a,n) for(lli i=a;i>=n;--i)
#define de(x) cout<<#x<<" is "<<x<<endl;
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define sizei 100000
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define te(tep) template<typename tep>
#define te2(tep1,tep2) template<typename tep1, typename tep2>
const double Pi=2*acos(0.0);

lli x;

te(t)
void vref(v(t) &v, t n, t f(t)){
  rei(i,1,n){
    t te; cin>>te;
    v.pb(f(te));
  }
}
te(t)
t fx(t a){
  if(a>=x)
    return a-x;
  else
    return a;
}
te(t)
void vre(v(t) &v, t n){
  rei(i,1,n){
    t te; cin>>te;
    v.pb(te);
  }
}
te(t)
void vdu(v(t) v){
  if(v.size()==0){
    cout<<"empty!!\n";
    return;
  }
  cout<<v.size()<<"(size)\n";
  rei(i,0,v.size()-1)
    cout<<v[i]<<",";
  cout<<"\n";
}
te2(t,tt)
void mdu(m(t,tt) q){
  /*if(q.size()==0){
    cout<<"empty!!\n";
    return;
  }*/
  cout<<q.size()<<"(size)\n";
  reit(i,q){
    cout<<"("<<i->ff<<":";vdu(i->second);cout<<")\n";
  }
  cout<<"\n";
}
te2(t,tt)
tt mxmap(m(t,tt) q,char x){
  p(t,tt) mx;
  mx={q.begin()->ff,q.begin()->ss};
  reit(i,q){
    if(mx.x<max(mx.x,i->x))
      mx={i->ff,i->ss};
  }
  return mx;
}
te(t)
t power2(t a){
  t val=1, temp=mod-2;
  while(temp>0){
    if(temp&1){
      val=(val*a)%mod;
    }
    a=(a*a)%mod;
    temp>>=1;
  }
  return val;
}
te(t)
t ma(t x, t y){
  return (((x)%mod+(y)%mod)%mod);
} 
te(t)
t ms(t x, t y){
  return ((((x)%mod-(y)%mod)%mod + mod)%mod);
}
te(t)
t mm(t x, t y){
  return (((x)%mod*(y)%mod)%mod);
}
te(t)
t md(t a, t b){
  return( ((a)%mod) * ((power2(b))%mod) )%mod;
}

/*const lli N=5*1e5+9;
bool prime_check[N];
v(lli) primes;

void seive(){
  memset(prime_check,true,sizeof(bool)*N);
  for(lli p=2;p*p<=N;++p){
    if(prime_check[p]){
      for(lli i=p*p;i<=N;i+=p){
        prime_check[i]=false;
      }
    }
  }

  rei(i,2,N){
    if(prime_check[i]) primes.pb(i);
  }
}*/

void solve(){
  lli n,k; cin>>n>>k;
  v(lli) a; vre(a,n); sort(all(a));
  lli sum=0;
  rei(i,0,k-1){
    sum+=a[i];
  }
  cout<<sum;
}


int main(){
  /*#ifndef ONLINE_JUDGE 
  freopen("input.txt", "r", stdin); 
  freopen("output.txt", "w", stdout); 
  #endif*/
  //auto start=high_resolution_clock::now();
    solve();

  //auto stop=high_resolution_clock::now(); auto duration=duration_cast<microseconds>(stop-start); cout<<endl<<"Time taken: "<<duration.count()<<" microseconds"<<endl; 
  return 0;
}

Measured memory_bytes: 3576