#include <bits/stdc++.h>
using namespace std;
int arr[1009];
inline void ins_sort(int p) {
  for (int c = 1; c < p; c++) {
    int d = c;
    while (d > 0 && arr[d] < arr[d - 1]) {
      int t = arr[d - 1];
      arr[d - 1] = arr[d];
      arr[d--] = t;
    }
  }
}
int main() {
  int n, m, max = 0, arr2[1009];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) scanf("%d", &arr[i]);
  ins_sort(m);
  for (int k = 0; k < m; k++) arr2[k] = arr[k];
  for (int i = 0; i < n; i++) {
    max += arr[m - 1];
    arr[m - 1]--;
    if (arr[m - 1] - arr[m - 2] < 0) ins_sort(m);
    if (arr[m - 1] == 0) break;
  }
  int min = 0;
  int x = 0;
  for (int i = 0; i < n; i++) {
    if (arr2[x] == 0) x++;
    min += arr2[x];
    arr2[x]--;
  }
  printf("%d %d", max, min);
  return 0;
}
