#include <bits/stdc++.h>
using namespace std;
int a[1005], i, m, n, mx, mn, k, z, p;
priority_queue<int> q;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a[i];
  }
  z = n;
  sort(a, a + m);
  for (i = 0; i < m; i++) {
    if (n < a[i]) {
      mn = mn + ((a[i] + 1) * a[i]) / 2 - (((a[i] - n) + 1) * (a[i] - n)) / 2;
      break;
    } else {
      mn = mn + ((a[i] + 1) * a[i]) / 2;
      n = n - a[i];
    }
  }
  for (i = 0; i < m; i++) {
    q.push(a[i]);
  }
  while (z > 0) {
    p = q.top();
    mx = mx + p;
    q.pop();
    q.push(p - 1);
    z--;
  }
  cout << mx << " " << mn;
}
