#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  priority_queue<int> pq;
  for (int i = 0; i < m; i++) {
    cin >> v[i];
    pq.push(v[i]);
  }
  int sum = 0, temp;
  for (int i = 1; i <= n; i++) {
    sum += pq.top();
    temp = pq.top();
    pq.pop();
    pq.push(temp - 1);
  }
  cout << sum << ' ';
  sort(v.begin(), v.end());
  sum = 0;
  for (int j = 0, i = 0; j < n; j++) {
    sum += v[i]--;
    if (v[i] == 0) i++;
  }
  cout << sum;
  return 0;
}
