#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e12;
const long long mod = 1e9 + 7;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
const long long MAXN = 1000 * 1000 + 10;
const long long N = 100 * 1000 + 10;
int a[N];
int main() {
  faster();
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    sum += a[i];
  }
  cout << sum << endl;
}
