#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + m);
  int mi = 0, ma = 0, k = 0, val = a[0];
  for (int i = 0; i < n; i++) {
    mi += val;
    --val;
    if (val == 0) val = a[++k];
  }
  if (n == sum)
    ma = mi;
  else {
    sort(a, a + m, greater<int>());
    while (n--) {
      ma += a[0];
      --a[0];
      sort(a, a + m, greater<int>());
    }
  }
  cout << ma << " " << mi;
  return 0;
}
