#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
int n, m, a[MAXN], b[MAXN];
int main() {
  int cnt = 0, maxAns = 0, minAns = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + m);
  sort(b, b + m);
  while (cnt < n) {
    maxAns += a[m - 1];
    a[m - 1]--;
    cnt++;
    sort(a, a + m);
  }
  cnt = 0;
  while (cnt < n) {
    for (int i = 0; i < m; i++) {
      if (cnt >= n) break;
      if (b[i] <= 0) continue;
      minAns += b[i];
      b[i]--;
      cnt++;
      break;
    }
  }
  cout << maxAns << " " << minAns << endl;
  return 0;
}
