#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned int n, k;
  unsigned int a[100];
  cin >> n >> k;
  while (n < k) {
    int tmp = n;
    n = k;
    k = tmp;
  }
  int kq = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (i < k) kq += a[i];
  }
  cout << kq;
  return 0;
}
