#include <bits/stdc++.h>
int main() {
  int n, m, i;
  scanf("%i%i", &n, &m);
  int v[m + 1];
  for (i = 0; i < m; i++) {
    scanf("%i", &v[i]);
  }
  int ma = n, me = 0;
  std::sort(v, v + m);
  i = 0;
  while (1) {
    if (v[i] < n) {
      me += (v[i] * (v[i] + 1)) / 2;
      n -= v[i];
      i++;
    } else {
      i = v[i];
      while (n--) {
        me += i;
        i--;
      }
      break;
    }
  }
  n = ma;
  ma = 0;
  for (i = 0; i < n; i++) {
    ma += v[m - 1];
    v[m - 1]--;
    std::sort(v, v + m);
  }
  printf("%i %i\n", ma, me);
  return 0;
}
