#include <bits/stdc++.h>
using namespace std;
long long int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m), s;
  for (int i = 0; i < m; i++) cin >> v[i], s.push_back(v[i]);
  sort(v.begin(), v.end());
  sort(s.rbegin(), s.rend());
  int min = 0, max = 0, p = n, end, curr = 0;
  while (p) {
    if (v[curr] <= p) {
      p -= v[curr];
      min += ((v[curr] + 1) * v[curr]) / 2;
    } else {
      for (int i = 0; i < p; i++) {
        min += v[curr];
        v[curr]--;
      }
      p = 0;
    }
    curr++;
  }
  curr = 0, end = m - 1;
  while (n) {
    n--;
    max += s[curr];
    s[curr]--;
    sort(s.rbegin(), s.rend());
  }
  cout << max << " " << min;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
