#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int n, m, a[1005], i = 0, maxx = 0, minn = 0;
  priority_queue<int> trex;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    trex.push(a[i]);
  }
  int k = n;
  while (n--) {
    maxx += trex.top();
    trex.push(trex.top() - 1);
    trex.pop();
  }
  sort(a, a + m);
  while (k--) {
    if (a[i] == 0) {
      i++;
    }
    minn += a[i];
    a[i]--;
  }
  cout << maxx << " " << minn;
  return 0;
}
