#include <bits/stdc++.h>
using namespace std;
void juice(int k, int arr[]) {
  int sum = 0;
  int n = sizeof(arr) / sizeof(arr[0]);
  sort(arr, arr + n);
  for (int i = 1; i <= k; ++i) {
    sum = sum + arr[i];
  }
  cout << sum;
}
int main() {
  int n, k, arr[1000];
  cin >> n;
  cin >> k;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  juice(k, arr);
}
