#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  for (int i = 0; i < (long long)m; i++) cin >> v[i];
  ;
  sort(v.begin(), v.end());
  vector<int> dup = v;
  int max = 0, min = 0;
  for (long long i = 0; i < (long long)n; i++) {
    max += v[m - 1];
    v[m - 1]--;
    sort(v.begin(), v.end());
  }
  int ix = 0;
  for (long long i = 0; i < (long long)n; i++) {
    if (dup[ix] == 0) ix++;
    min += dup[ix];
    dup[ix]--;
    sort(dup.begin(), dup.end());
  }
  cout << max << " " << min;
  return 0;
}
