#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m, i, mn = 0, mx = 0;
  cin >> n >> m;
  long long int a[m + 1];
  priority_queue<long long int> pq;
  for (i = 1; i <= m; i++) {
    cin >> a[i];
    pq.push(a[i]);
  }
  sort(a + 1, a + m + 1);
  long long int x = n, v;
  i = 1;
  while (x > 0) {
    while (x > 0 && a[i] > 0) {
      mn += a[i];
      a[i]--;
      x--;
    }
    i++;
  }
  i = 1;
  while (n > 0) {
    x = pq.top();
    mx += x;
    pq.pop();
    n--;
    pq.push(x - 1);
  }
  cout << mx << " " << mn << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int t;
  solve();
  return 0;
}
