#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = int64_t;
using vi = vector<int>;
using vll = vector<ll>;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long bikkuri(long long k) {
  long long sum = 1;
  for (long long i = 1; i <= k; ++i) {
    sum *= i;
  }
  return sum;
}
int main() {
  int n, m;
  cin >> n >> m;
  vi a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int k = 0;
  for (int i = 0; i < m; i++) {
    k += a.at(i);
  }
}
