#include <bits/stdc++.h>
using namespace std;
bool scan_column_for_bricks(const vector<vector<char>>& walls, int col) {
  for (int r = 0; r < walls.size(); r++) {
    if (walls[r][col] == 'B') return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  vector<int> nums(a);
  for (int i = 0; i < a; i++) cin >> nums[i];
  sort(nums.begin(), nums.end());
  int sum = 0;
  for (int i = 0; i < b; i++) {
    sum += nums[i];
  }
  cout << sum;
}
