#include <bits/stdc++.h>
using namespace std;
long long a[100005];
long long aa[100005];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long move(int i, int j, long long s[]) {
  long long a;
  long long b;
  int x, y;
  int gc;
  a = s[i];
  b = s[j];
  gc = gcd(a, b);
  x = a, y = b;
  int cns = 0;
  while (1) {
    int d = gcd(x, y);
    d /= gc;
    if (!(d & 1)) {
      s[i] = x, s[j] = y;
      return cns;
    }
    long long tp = x;
    x = x - y;
    y = tp + y;
    cns++;
  }
}
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i <= n - 1; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long sum = 0;
  for (int i = 0; i <= k - 1; i++) sum += a[i];
  printf("%d\n", sum);
  return 0;
}
