#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  ll pi;
  vector<ll> p;
  for (ll i=0;i<N;i++) {
  	cin >> pi;
    p.push_bask(pi);
  }
  sort(p.begin(), p.end());
  
  ll sum=0;
  for (ll i=0;i<K;i++) {
  	sum+=p[i];
  }
  cout << sum;
}
