#include <bits/stdc++.h>
using namespace std;
int A[1];
int size = 1;
int m = 2;
bool prime(long long n) {
  if (n == 1) return false;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) {
      return false;
    }
  return true;
}
void prime_fact(int n) {
  for (int i = 2; i * i <= n; i++) {
    int count = 0;
    if (n % i == 0) {
      while (n % i == 0) n /= i, count++;
      cout << i << "^" << count << " ";
    }
  }
  if (n > 1) cout << n << "^1";
}
long long power(long long base, long long pow) {
  long long res = 1;
  while (pow > 0) {
    if (pow & 1)
      res *= base, pow -= 1;
    else
      base *= base, pow /= 2;
  }
  return res;
}
void prime_fact_seieve(int n) {
  for (int i = 2; i <= size; i++) {
    if (A[i] == 0)
      for (long long j = i; j <= size; j += i)
        if (A[i] == 0) A[j] = i;
  }
  while (n > 2) {
    cout << A[n] << "*";
    n /= A[n];
  }
}
template <class X>
X gcd(X a, X b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <class X>
X lcm(X a, X b) {
  return a / gcd(a, b) * b;
}
long long Ab[101][101], I[101][101];
void multiply(long long I[][101], long long A[][101], int dim) {
  int res[dim + 1][dim + 1];
  for (int i = 0; i < dim; i++) {
    for (int j = 0; j < dim; j++) {
      res[i][j] = 0;
      for (int k = 0; k < dim; k++) {
        res[i][j] +=
            ((I[i][k] % 1000000007) * (A[k][j]) % 1000000007) % 1000000007;
      }
    }
  }
  for (int i = 0; i < dim; i++)
    for (int j = 0; j < dim; j++) I[i][j] = res[i][j];
}
void powerMat(long long A[][101], int dim, int n) {
  for (int i = 0; i < dim; i++)
    for (int j = 0; j < dim; j++) {
      if (i == j)
        I[i][j] = 1;
      else
        I[i][j] = 0;
    }
  while (n > 0) {
    if (n % 2)
      multiply(I, A, dim), n--;
    else
      multiply(A, A, dim), n /= 2;
  }
  for (int i = 0; i < dim; i++)
    for (int j = 0; j < dim; j++) A[i][j] = I[i][j];
}
void printMat(long long A[][101], int dim) {
  for (int i = 0; i < dim; i++) {
    for (int j = 0; j < dim; j++) {
      cout << A[i][j] << " ";
    }
    cout << "\n";
  }
}
long long power(long long base, long long pow, long long mo) {
  long long res = 1;
  while (pow > 0) {
    if (pow & 1)
      res = (res % mo * base % mo) % mo, pow -= 1;
    else
      base = (base % mo * base % mo) % mo, pow /= 2;
  }
  return res;
}
int main() {
  int n, k;
  long long sum = 0;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  for (int i = 0; i < k; i++) sum += arr[i];
  cout << sum;
}
