#include <bits/stdc++.h>
using namespace std;
int knapsack(int w[], int v[], int W, int n) {
  int dp[n + 1][W + 1];
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = 0; j <= W; j++) {
      if (i == 0 || j == 0) dp[i][j] = 0;
    }
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= W; j++) {
      if (w[i - 1] <= j)
        dp[i][j] = max((v[i - 1] + dp[i - 1][j - w[i - 1]]), dp[i - 1][j]);
      else if (w[i - 1] > j)
        dp[i][j] = dp[i - 1][j];
    }
  }
  return dp[n][W];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n, k;
  long long int a[n], b[n], sum = 0;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (long long int i = 0; i < k; i++) sum += a[i];
  cout << sum << endl;
}
