#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> A(m), B(m);
  for (long long i = 0; i < m; i++) {
    cin >> A[i];
    B[i] = A[i];
  }
  long long pas = n;
  long long max = 0, min = 0;
  while (pas) {
    sort(B.begin(), B.end());
    if (B[m - 1] > 0) {
      max += B[m - 1];
      B[m - 1]--;
    }
    pas--;
  }
  sort(A.begin(), A.end());
  for (long long i = 0; i < m; i++) {
    while (A[i]) {
      n--;
      min += A[i];
      A[i]--;
      if (n == 0) {
        break;
      }
    }
    if (n == 0) {
      break;
    }
  }
  cout << max << " " << min << endl;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
