import 'dart:io';

void main(List<String> arguments) {
  final nk = stdin.readLineSync().split(' ');
  final k = int.parse(nk[1]);
  final result =
      (stdin.readLineSync().split(' ').map((p) => int.parse(p)).toList()
            ..sort())
          .take(k)
          .fold(0, (previousValue, element) => previousValue + element);
  print(result);
}
