#include <bits/stdc++.h>
int main() {
  unsigned passangers_count = 0;
  unsigned airplanes_count = 0;
  scanf("%d %d", &passangers_count, &airplanes_count);
  std::priority_queue<int> maxPriority, minPriority;
  for (unsigned i = 0, airplane_capacity = 0; i < airplanes_count; ++i) {
    scanf("%d", &airplane_capacity);
    maxPriority.push(airplane_capacity);
    minPriority.push(-airplane_capacity);
  }
  int min = 0, max = 0;
  for (int minPrice = 0, maxPrice = 0; passangers_count; --passangers_count) {
    minPrice = minPriority.top();
    min += -minPrice;
    minPriority.pop();
    if (minPrice < -1) minPriority.push(minPrice + 1);
    maxPrice = maxPriority.top();
    max += maxPrice;
    maxPriority.pop();
    maxPriority.push(maxPrice - 1);
  }
  printf("%d %d", max, min);
  return 0;
}
