#include <bits/stdc++.h>
using namespace std;
int solveMin(vector<int>& a, int n) {
  int res = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (n <= a[i]) {
      res += (2 * a[i] - n + 1) * n / 2;
      break;
    } else {
      res += (a[i] + 1) * a[i] / 2;
      n -= a[i];
    }
  }
  return res;
}
int solveMax(vector<int> a, int n) {
  int res = 0, sz = a.size();
  for (int i = sz - 1; i;) {
    if (a[i] > a[i - 1]) {
      if (sz - i >= n) {
        res += n * a[i];
        return res;
      }
      res += (sz - i) * a[i];
      n -= (sz - i);
      --a[i];
    } else {
      --i;
    }
  }
  while (n) {
    res += min(n, sz) * a[0];
    n -= min(n, sz);
    --a[0];
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  cout << solveMax(a, n) << " " << solveMin(a, n);
  return 0;
}
