#include <bits/stdc++.h>
using namespace std;
priority_queue<int, vector<int>, less<int> > q1;
priority_queue<int, vector<int>, greater<int> > q2;
int main() {
  int n, m;
  while (cin >> n >> m) {
    int i, tot1 = 0, tot2 = 0;
    for (i = 0; i < m; i++) {
      int input;
      cin >> input;
      q1.push(input);
      q2.push(input);
    }
    for (i = 0; i < n; i++) {
      int number = q1.top();
      q1.pop();
      tot1 += number;
      if (number > 1) q1.push(number - 1);
      number = q2.top();
      q2.pop();
      tot2 += number;
      if (number > 1) q2.push(number - 1);
    }
    cout << tot1 << " " << tot2 << endl;
  }
  return 0;
}
