#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, temp;
  cin >> n >> m;
  int a[1000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int c = i; c < n; c++) {
      if (a[i] > a[c + 1]) {
        temp = a[i];
        a[i] = a[c + 1];
        a[c + 1] = temp;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < m; i++) {
    sum += a[i];
  }
  cout << sum;
  return 0;
}
