#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int empty[m + 1], copy[m + 1];
  for (int i = 0; i < m; i++) cin >> empty[i];
  sort(empty, empty + m);
  for (int i = 0; i < m; i++) {
    copy[i] = empty[i];
  }
  int MIN = 0, minindex = 0, MAX = 0, maxindex = m - 1;
  for (int i = 0; i < n; i++) {
    MIN += copy[minindex];
    copy[minindex]--;
    if (copy[minindex] == 0) minindex++;
  }
  cout << endl;
  for (int i = 0; i < n; i++) {
    MAX += empty[m - 1];
    empty[m - 1]--;
    sort(empty, empty + m);
  }
  cout << MAX << " " << MIN << endl;
  return 0;
}
