#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  vector<int> v2;
  int i, minfare = 0, maxfare = 0;
  for (i = 0; i < m; i++) {
    int x;
    cin >> x;
    v.push_back(x);
    v2.push_back(x);
  }
  sort(v.begin(), v.end());
  int count = 0;
  int planenumber = 0;
  while (count < n) {
    while (v[planenumber] != 0 && count < n) {
      minfare += v[planenumber];
      v[planenumber]--;
      count++;
    }
    if (count < n) {
      planenumber++;
    }
  }
  sort(v2.begin(), v2.end());
  int maxcount = 0;
  while (maxcount < n) {
    maxfare += v2[m - 1];
    v2[m - 1]--;
    maxcount++;
    sort(v2.begin(), v2.end());
  }
  cout << maxfare << " " << minfare;
  return 0;
}
