#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[1005], b[1005];
  while (scanf("%d%d", &n, &m) != EOF) {
    int i, maxnum = 0, minnum = 0, temp, j = 0;
    for (i = 0; i < m; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
    }
    sort(a, a + m);
    for (i = 0; i < n; i++) {
      maxnum += a[m - 1];
      a[m - 1]--;
      sort(a, a + m);
    }
    sort(b, b + m);
    for (i = 0; i < n; i++) {
      while (b[j] <= 0) j++;
      minnum += b[j];
      b[j]--;
      sort(b, b + m);
    }
    printf("%d %d\n", maxnum, minnum);
  }
  return 0;
}
