#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> plane(m);
  for (int i = 0; i < m; i++) cin >> plane[i];
  sort(plane.begin(), plane.end());
  vector<int> Mplane(m);
  for (int i = 0; i < m; i++) Mplane[i] = plane[i];
  long long max = 0, min = 0;
  int temp = n;
  long long totalMax = 0, totalMin = 0;
  while (temp > 0) {
    max = 0;
    int index = 0;
    for (int i = plane.size() - 1; i >= 0; i--) {
      if (plane[i] < max) {
        break;
      } else {
        max = plane[i];
        index = i;
      }
    }
    totalMax += plane[index];
    plane[index]--;
    temp--;
  }
  while (n > 0) {
    int index = 0;
    min = Mplane[m - 1] + 1000000;
    for (int i = 0; i < Mplane.size(); i++) {
      if (Mplane[i] > min)
        break;
      else {
        if (Mplane[i] != 0) {
          min = Mplane[i];
          index = i;
        }
      }
    }
    totalMin += Mplane[index];
    Mplane[index]--;
    n--;
  }
  cout << totalMax << " " << totalMin << endl;
  return 0;
}
