#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) {
  return {l.first + r.first, l.second + r.second};
}
typedef void (*callback_function)(void);
const long long INF64 = 1e18;
const long long INF32 = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  {
    long long n, m;
    cin >> n >> m;
    long long a[m], b[m];
    for (long long i = (0); i < (m); i++) {
      cin >> a[i];
    }
    sort(a, a + m);
    for (long long i = (0); i < (m); i++) {
      b[i] = a[i];
    }
    long long maxA = 0, minA = 0, i = 0;
    while (n--) {
      maxA += a[m - 1];
      a[m - 1]--;
      sort(a, a + m);
      while (b[i] == 0) {
        i++;
      }
      minA += b[i];
      b[i]--;
    }
    cout << maxA << ' ' << minA << endl;
  }
  return 0;
}
