#include <bits/stdc++.h>
using namespace std;
struct IInt {
  int z;
};
bool cmp(int a, int b) { return a < b; }
bool operator<(IInt a, IInt b) { return a.z > b.z; }
int main() {
  int n, m, x, i, ans, ans1;
  IInt t;
  scanf("%d%d", &n, &m);
  vector<int> q;
  priority_queue<IInt> w;
  for (i = 0; i < m; i++) {
    scanf("%d", &x);
    q.push_back(x);
    t.z = x;
    w.push(t);
  }
  make_heap(q.begin(), q.end(), cmp);
  ans = ans1 = 0;
  for (i = 0; i < n; i++) {
    ans += q[0];
    q[0]--;
    make_heap(q.begin(), q.end(), cmp);
  }
  for (i = 0; i < n; i++) {
    t = w.top();
    w.pop();
    ans1 += t.z;
    if (t.z == 1) {
      continue;
    } else {
      t.z--;
      w.push(t);
    }
  }
  printf("%d %d\n", ans, ans1);
  return 0;
}
