#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  vector<long long> v;
  for (long long i = 0; i < m; i++) {
    long long a;
    cin >> a;
    v.push_back(a);
  }
  long long keys = 0;
  vector<long long> v1;
  for (long long i = 0; i < m; i++) {
    v1.push_back(v[i]);
  }
  long long s = n;
  long long key = 0;
  while (n > 0) {
    long long maxm = *max_element(v.begin(), v.end());
    key += maxm;
    for (long long i = 0; i < m; i++) {
      if (v[i] == maxm) {
        v[i]--;
        break;
      }
    }
    n--;
  }
  while (s > 0) {
    sort(v1.begin(), v1.end());
    long long minm = *min_element(v1.begin(), v1.end());
    keys += minm;
    for (long long i = 0; i < m; i++) {
      if (v1[i] == minm) {
        if (minm != 0) {
          v1[i]--;
          break;
        } else {
          s++;
          v1.erase(v1.begin());
        }
      }
    }
    s--;
  }
  cout << key << " " << keys << "\n";
}
