#include <bits/stdc++.h>
using namespace std;
int bata[1020];
int main() {
  int n, m, sum = 0, sum1 = 0, k;
  scanf("%d%d", &n, &m);
  k = n;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &bata[i]);
  }
  sort(bata + 1, bata + m + 1);
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < bata[i]; j++) {
      if (k > 0) {
        sum = sum + bata[i] - j;
        k--;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int j = max_element(bata + 1, bata + m + 1) - bata;
    sum1 = sum1 + bata[j];
    bata[j]--;
  }
  printf("%d %d\n", sum1, sum);
  return 0;
}
