#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int i, j = 0, k, a = 0, b = 0, n, m, x;
  vector<int> vec, vec1;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x;
    vec.push_back(x);
    vec1.push_back(x);
  }
  sort(vec.begin(), vec.end());
  while (n--) {
    sort(vec1.begin(), vec1.end());
    a += vec1[m - 1];
    vec1[m - 1]--;
    if (vec[j] <= 0) j++;
    b += vec[j];
    vec[j]--;
  }
  cout << a << " " << b;
}
