#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  multiset<int> mini, maxi;
  for (int i = 0, x; i < m; ++i) cin >> x, mini.insert(x);
  maxi = mini;
  int mx = 0, mn = 0;
  int j = 0;
  while (j++ < n) {
    int k = *maxi.rbegin();
    mx += k, maxi.erase(prev(maxi.end()));
    k--;
    if (k > 0) maxi.insert(k);
  }
  j = 0;
  while (j++ < n) {
    int k = *mini.begin();
    mn += k;
    mini.erase(mini.begin());
    --k;
    if (k > 0) mini.insert(k);
  }
  cout << mx << " " << mn << endl;
  return 0;
}
