#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m];
  vector<int> v;
  int n1 = n;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(a, a + m);
  int mi = 0;
  for (int i = 0; i < m; i++) {
    while (n > 0) {
      mi = mi + a[i];
      a[i]--;
      n--;
      if (a[i] <= 0) {
        break;
      }
    }
  }
  int ma = 0;
  while (n1 > 0) {
    sort(v.begin(), v.end());
    ma = ma + v[m - 1];
    v[m - 1]--;
    n1--;
  }
  cout << ma << " " << mi;
  return 0;
}
