#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int a[m];
  for (int i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  int min_ans = 0, max_ans = 0;
  int i = 0, c = 0, x = a[0], j = 0;
  while (c < n) {
    if (x == 0) {
      i++;
      x = a[i];
    }
    min_ans += x;
    x--;
    c++;
  }
  sort(a, a + m, cmp);
  i = 0, c = 0, x = a[0];
  while (c < n) {
    if (a[i] > a[i + 1] or i == m - 1) {
      if (a[i] <= a[i - 1]) {
        max_ans += a[i] * min(i + 1, n - c);
        c += min(i + 1, n - c);
      } else {
        max_ans += a[i];
        c++;
      }
      a[i]--;
    } else if (a[i] == a[i + 1]) {
      if (a[i] <= a[i - 1]) {
        max_ans += a[i] * min(i + 1, n - c);
        c += min(i + 1, n - c);
        a[i]--;
      } else {
        max_ans += a[i];
        a[i]--;
        c++;
      }
    } else if (i < m - 1)
      i++;
  }
  cout << max_ans << ' ' << min_ans << endl;
  return 0;
}
