#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x, i;
  vector<long long> a, b;
  cin >> n >> m;
  priority_queue<long long> q;
  for (i = 0; i < m; i++) {
    cin >> x;
    q.push(x);
    b.push_back(x);
  }
  long long mx = 0, mn = 0, j = 0;
  sort(b.begin(), b.end());
  for (i = 0; i < n; i++) {
    mx += q.top();
    long long s = q.top();
    q.pop();
    s--;
    if (s > 0) q.push(s);
  }
  j = 0;
  for (i = 0; i < n; i++) {
    if (b[j] == 0) j++;
    mn += b[j];
    b[j]--;
  }
  cout << mx << " " << mn;
}
