#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[m];
  for (int i = (0); i < (m); i++) {
    cin >> arr[i];
  }
  sort(arr, arr + m);
  int minimum(0), num(arr[0]), k(0);
  for (int i = 0; i < n; ++i) {
    minimum += num;
    num -= 1;
    if (num == 0) {
      num = arr[++k];
    }
  }
  sort(arr, arr + m, greater<int>());
  int maxi = 0;
  while (n--) {
    maxi += arr[0];
    arr[0]--;
    for (int i = (1); i < (m); i++) {
      if (arr[i] <= arr[i - 1]) {
        break;
      }
      swap(arr[i], arr[i - 1]);
    }
  }
  cout << maxi << " " << minimum;
  return 0;
}
