#include <bits/stdc++.h>
using namespace std;
inline int read();
int a[14250];
unsigned long long ans;
bool cmp(int a, int b) { return a < b; }
int main() {
  int n = read(), k = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= k; i++) {
    ans += a[i];
  }
  cout << ans;
  return 0;
}
inline int read() {
  int x = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * w;
}
