#include <bits/stdc++.h>
int main() {
  int n, m, sum_max{0}, sum_min{0};
  scanf("%d %d", &n, &m);
  int arr[m];
  for (int i = 0; i < m; i++) scanf("%d", &arr[i]);
  std::sort(arr, arr + m);
  int j = 0, num = arr[0];
  for (int i = 0; i < n; i++) {
    if (num == 0) num = arr[++j];
    sum_min += num;
    num--;
  }
  std::sort(arr, arr + m, std::greater<int>());
  for (int i = 0; i < n; i++) {
    for (int i = 1; i < m; i++) {
      if (arr[i - 1] > arr[i]) break;
      std::swap(arr[i - 1], arr[i]);
    }
    sum_max += arr[0];
    --arr[0];
  }
  std::cout << sum_max << ' ' << sum_min;
  return 0;
}
