#include <bits/stdc++.h>
int main(void) {
  int N, K;
  scanf("%d%d", &N, &K);
  int p[N];
  for (int i = 0; i < K; i++) {
    scanf("%d", &p[i]);
  }
  int s;
  int sum = 0;
  for (int k = 0; k < N; k++) {
    for (int j = k; j < N; j++) {
      if (p[j] < p[k]) {
        s = p[k];
        p[k] = p[j];
        p[j] = s;
      }
    }
  }
  for (int l = 0; l < K; l++) {
    sum = sum + p[l];
  }
  printf("%d\n", sum);
  return 0;
}
