#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tostr(const T& t) {
  ostringstream os;
  os << t;
  return os.str();
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  int n, m, ai;
  priority_queue<int> q1;
  priority_queue<int, vector<int>, greater<int> > q2;
  int ma, mi;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> ai;
    q1.push(ai);
    q2.push(ai);
  }
  ma = mi = 0;
  for (int i = 0; i < n; ++i) {
    if (q1.empty()) break;
    int x = q1.top();
    q1.pop();
    ma += x;
    --x;
    if (x > 0) q1.push(x);
  }
  for (int i = 0; i < n; ++i) {
    if (q2.empty()) break;
    int x = q2.top();
    q2.pop();
    mi += x;
    --x;
    if (x > 0) q2.push(x);
  }
  cout << ma << " " << mi << endl;
  return 0;
}
