#include <bits/stdc++.h>
using namespace std;
string itosm(long long x) {
  if (x == 0) return "0";
  string ans = "";
  while (x > 0) {
    ans += ((x % 10) + '0');
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long stoim(string str) {
  long long ans = 0;
  long long k = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += (str[i] - '0') * k;
    k *= 10;
  }
  return ans;
}
const int inf = 2009000999;
const double eps = 1e-6;
const int maxn = 1e5 + 5;
const int maxk = 51;
const int baseint = 1000200013;
const long long basell = 1e18 + 3;
const long double PI = acos(-1.0);
int p[maxn];
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(0);
  ;
  int n, k;
  cin >> n >> k;
  for (int i = (0); i < (n); i++) cin >> p[i];
  sort(p, p + n);
  int sum = 0;
  for (int i = (0); i < (k); i++) sum += p[i];
  cout << sum;
  return 0;
}
