#include <bits/stdc++.h>
using namespace std;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void inout() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int ara[n + 10];
  for (int i = 1; i <= n; i++) {
    cin >> ara[i];
  }
  sort(ara + 1, ara + n + 1);
  long long int sum = 0;
  for (int i = 1; i <= k; i++) {
    sum += ara[i];
  }
  cout << sum;
}
int main() {
  faster();
  inout();
  solve();
  return 0;
}
