#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
struct cmp {
  bool operator()(int a, int b) { return b < a; }
};
class Solution {
 public:
  char sol(char c) { return c >= 'a' && c <= 'z' ? 'a' : 'A'; }
};
int main(int argc, char const *argv[]) {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
  }
  int res = 0;
  sort(arr.begin(), arr.end());
  for (int i = 0; i < k; i++) res += arr[i];
  cout << res << endl;
  return res;
}
