#include <bits/stdc++.h>
using namespace std;
int a[1050], b[1050];
int main() {
  int n, m, s = 0, d = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (int i = 1; i <= n; i++) {
    sort(a, a + m);
    for (int j = 0; j < m; j++) {
      if (a[j] > 0) {
        s += a[j];
        a[j]--;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(b, b + m);
    for (int j = m - 1; j >= 0; j--) {
      if (b[j] > 0) {
        d += b[j];
        b[j]--;
        break;
      }
    }
  }
  cout << d << " " << s;
  return 0;
}
