#include <bits/stdc++.h>
using namespace std;
string p;
vector<long long> v;
vector<long long> vv;
long long siz;
void setfil(long long x) {
  while (x) {
    v.push_back(x--);
    siz++;
  }
}
int main() {
  long long mx = 0, mn = 0, temp = 0, ln = 0;
  long long n, m;
  cin >> n >> m;
  long long x;
  while (m--) {
    cin >> x;
    setfil(x);
    vv.push_back(x);
    ln++;
  }
  long long p = n;
  sort(v.begin(), v.end());
  while (p--) mx += v[--siz];
  sort(vv.begin(), vv.end());
  while (1) {
    if (temp >= n)
      break;
    else {
      for (long long i = 0; i < ln; i++) {
        for (int k = vv[i]; k > 0; k--) {
          if (temp >= n) break;
          temp++;
          mn = mn + k;
        }
      }
    }
  }
  cout << mx << " " << mn;
}
