#include <bits/stdc++.h>
using namespace std;
long double EPS = 0.000000001;
int di[] = {0, 1, 0, -1};
int dj[] = {1, 0, -1, 0};
int sum(int n) { return (n * (n + 1)) / 2; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  priority_queue<int> q;
  for (int i = 0; i < m; i++) {
    cin >> v[i];
    q.push(v[i]);
  }
  sort(v.begin(), v.end());
  int ct = n;
  int res = 0;
  for (; ct > 0; ct--) {
    int a = q.top();
    q.pop();
    res += a;
    if (a > 0) q.push(a - 1);
  }
  cout << res << ' ';
  res = 0;
  ct = n;
  for (int i = 0; i < m && ct > 0; i++) {
    if (ct >= v[i]) {
      res += sum(v[i]);
      ct -= v[i];
    } else {
      res += sum(v[i]);
      res -= sum(v[i] - ct);
      ct = 0;
    }
  }
  cout << res << endl;
}
