#include <bits/stdc++.h>
using namespace std;
int main() {
  int N = 0;
  int* juice;
  int K;
  int total = 0;
  juice = new int[N];
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> juice[i];
  }
  sort(juice, juice + N);
  for (int j = 0; j < K; j++) {
    total = total + juice[j];
  }
  cout << total;
  return 0;
}
