#include <bits/stdc++.h>
using namespace std;
bool comp(const int& a, const int& b) { return a > b; }
int main() {
  int n, m, temp, cost, cost_min, tot;
  vector<int> seats, seats_min;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &temp);
    seats.push_back(temp);
  }
  seats_min = seats;
  tot = n;
  make_heap(seats.begin(), seats.end());
  cost = 0;
  while (n--) {
    temp = seats.front();
    cost += temp;
    pop_heap(seats.begin(), seats.end());
    seats.pop_back();
    temp -= 1;
    if (temp > 0) {
      seats.push_back(temp);
      push_heap(seats.begin(), seats.end());
    }
  }
  make_heap(seats_min.begin(), seats_min.end(), comp);
  cost_min = 0;
  while (tot--) {
    temp = seats_min.front();
    cost_min += temp;
    temp--;
    pop_heap(seats_min.begin(), seats_min.end(), comp);
    seats_min.pop_back();
    if (temp > 0) {
      seats_min.push_back(temp);
      push_heap(seats_min.begin(), seats_min.end(), comp);
    }
  }
  cout << cost << " " << cost_min << "\n";
  return 0;
}
