#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, i, j, mn = 0, mx = 0;
  cin >> n >> m;
  vector<long long> a(m), b(m);
  for (i = 0; i < m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (i = 0; i < n; i++) {
    sort(a.begin(), a.end());
    for (j = 0; j < m; j++) {
      if (a[j] > 0) {
        mn += a[j];
        a[j]--;
        break;
      }
    }
  }
  for (i = 0; i < n; i++) {
    sort(b.begin(), b.end());
    mx += b[m - 1];
    b[m - 1]--;
  }
  cout << mx << " " << mn << endl;
  return 0;
}
