#include <bits/stdc++.h>
#pragma comment(linker, "/stack:640000000")
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
const int N = 110;
int cost[N][N];
int col[N], res[N];
vector<int> adj[N];
void dfs(int u, int src) {
  for (int i = 0; i < adj[src].size(); i++) {
    int v = adj[src][i];
    if (u == v) {
      res[u] = max(res[u], cost[u][src]);
      continue;
    }
    dfs(src, v);
    res[src] = max(res[src], cost[v][src] + res[v]);
  }
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    int k;
    scanf("%d", &k);
    int arr[n + 10];
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    sort(arr, arr + n);
    int sum = 0;
    for (int i = 0; i < k; i++) sum += arr[i];
    printf("%d\n", sum);
  }
  return 0;
}
