#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N;
  cin >> K;
  int *array = new int[N];
  int *array2 = new int[K];
  for (int i = 0; i < N; i++) {
    cin >> array[i];
  }
  sort(array, array + 5);
  int ANS = 0;
  for (int i = 0; i < K; i++) {
    ANS += array[i];
  }
  cout << ANS;
  delete[] array;
  delete[] array2;
}
