#include <bits/stdc++.h>
using namespace std;
bool Sort(int z, int y) { return z > y; }
int main() {
  vector<int> a;
  vector<int> b;
  int n, m, x;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x;
    a.push_back(x);
    b.push_back(x);
  }
  long long i = 0, maxi = 0, mini = 0, getmax = 0, index = -1;
  x = 0;
  sort(a.begin(), a.end(), Sort);
  while (i < n) {
    for (int j = 0; j < a.size(); j++) {
      if (getmax < a[j]) {
        getmax = a[j];
        index = j;
      }
    }
    a[index]--;
    maxi += getmax;
    index = -1;
    getmax = 0;
    i++;
  }
  cout << maxi << " ";
  sort(b.begin(), b.end());
  x = 0, i = 0;
  while (i < n) {
    if (b[x] == 0) x++;
    mini += b[x];
    b[x]--;
    i++;
  }
  cout << mini;
  return 0;
}
