#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, sum = 0;
  cin >> a >> b;
  vector<int> vec;
  for (int i = 0; i < a; i++) {
    cin >> c;
    vec.push_back(c);
  }
  cout << b << endl;
  sort(vec.begin(), vec.end());
  for (int i = 0; i < b; i++) {
    sum += vec.at(i);
  }
  cout << sum << endl;
}
