#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int max = 0, min = 0;
  int a[m], b[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + m, greater<int>());
  for (int i = 0; i < n; i++) {
    if (a[0] != 0) {
      max = max + a[0];
      a[0] = a[0] - 1;
      sort(a, a + m, greater<int>());
    } else {
      break;
    }
  }
  sort(b, b + m);
  int i = 0, k = 0;
  while (i != n) {
    if (b[k] != 0) {
      min = min + b[k];
      b[k] = b[k] - 1;
    } else {
      k++;
      min = min + b[k];
      b[k] = b[k] - 1;
    }
    i++;
  }
  cout << max << " " << min;
  return 0;
}
