#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main()
{
int P, N;
cin >> P >> N;
long long res = 0;
int cnt = 0;
vector<int> V(N);
for (int i=0; i<N; i++)
cin >> V[i];
sort(V.begin(), V.end());
P --;
for (int i=0; i<N; i++) {
if (P >= V[i]) {
cnt ++;
res += P;
P -= V[i];
}
}
cout << cnt << " " << res << endl;
}