#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, a[1000], b[1000], s = 0, min = 0, max = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    s += a[i];
    b[i] = a[i];
  }
  sort(a, a + m);
  sort(b, b + m);
  int x = n;
  for (int i = 0; i < m; i++) {
    while (a[i] and x) {
      min += a[i];
      x -= 1;
      a[i] -= 1;
    }
  }
  while (n--) {
    max += b[m - 1];
    b[m - 1] -= 1;
    for (int i = m - 1; i >= 1; i--) {
      if (b[i] >= b[i - 1]) {
        break;
      }
      swap(b[i - 1], b[i]);
    }
  }
  cout << max << " " << min;
  return 0;
}
