import 'dart:io';

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

  print(n);
  print(k);
  print(result);
}
