#include <bits/stdc++.h>
using namespace std;
int seat[1010];
int main() {
  int n, m, i, j, k, max, min;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i < m; i++) {
      scanf("%d", &seat[i]);
    }
    sort(seat, seat + m);
    min = max = 0;
    k = n;
    i = 0;
    while (k > 0) {
      if (k >= seat[i]) {
        k -= seat[i];
        min += seat[i] * (seat[i] + 1) / 2;
        i++;
      } else {
        min += (seat[i] - k + 1 + seat[i]) * k / 2;
        k = 0;
      }
    }
    k = n;
    while (k > 0) {
      j = m - 1;
      while (j > 0 && seat[j] == seat[j - 1]) {
        j--;
      }
      max += seat[j];
      seat[j]--;
      k--;
    }
    printf("%d %d\n", max, min);
  }
  return 0;
}
