#include <bits/stdc++.h>
using namespace std;
int di[8] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dj[8] = {0, 0, -1, 1, 0, 0, 0, 0};
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  map<int, int> M, rec;
  for (int k = 0; k < (m); ++k) {
    int t;
    cin >> t;
    ++M[t];
  }
  rec = M;
  map<int, int>::iterator it = M.end();
  --it;
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < (n); ++i) {
    ans1 += it->first;
    ++M[it->first - 1];
    if (--(it->second) == 0) {
      M.erase(it--);
    }
  }
  M = rec;
  for (int i = 0; i < (n); ++i) {
    it = M.begin();
    ans2 += it->first;
    if (it->first > 1) ++M[it->first - 1];
    if (--(it->second) == 0) {
      M.erase(it);
    }
  }
  printf("%d %d\n", ans1, ans2);
  return 0;
}
