#include <bits/stdc++.h>
using namespace std;
int pmax[10000];
int pmin[10000];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  int amin = 0, amax = 0;
  int i, j, k;
  for (i = 0; i < m; i++) {
    scanf("%d", &pmax[i]);
    pmin[i] = pmax[i];
  }
  for (i = 0; i < n; i++) {
    k = 0;
    while (pmin[k] <= 0) k++;
    for (j = k; j < m; j += 1)
      if (pmin[j] > 0 && pmin[k] > pmin[j]) k = j;
    amin += pmin[k];
    pmin[k]--;
  }
  for (i = 0; i < n; i++) {
    k = 0;
    while (pmax[k] <= 0) k++;
    for (j = k; j < m; j += 1)
      if (pmax[j] > 0 && pmax[k] < pmax[j]) k = j;
    amax += pmax[k];
    pmax[k]--;
  }
  printf("%d %d", amax, amin);
  return 0;
}
