#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  vector<int> A;
  int ans;
  cin >> N >> K;
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  auto it = A.begin();
  for (int i = 1; i <= K; i++) {
    ans += *it;
    it++;
  }
  cout << ans << endl;
  return 0;
}
