#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  int juice[1005];
  cin >> a >> b;
  for (int i = 0; i < a; ++i) {
    cin >> juice[i];
  }
  sort(juice, juice + a);
  int ans = 0;
  for (int i = 0; i < b; ++i) {
    ans += juice[i];
  }
  cout << ans << "\n";
}
