#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int p[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  int count = 0;
  int sum = 0;
  int Min = p[0];
  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      Min = min(p[i], Min);
    }
    sum += Min;
    count++;
    if (count == K) {
      break;
    }
  }
  cout << sum << endl;
}
