#include <bits/stdc++.h>
using namespace std;
inline bool compare(double a, double b) { return fabs(a - b) < 1e-9; }
int i, j, l, n, x = 1, cnt, sm, fg, a[1010], b[1010];
char ch[1010];
int gcd(int a, int b) {
  while (b > 0) {
    a %= b;
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return a;
}
int main() {
  int m;
  while (~scanf("%d%d", &m, &n)) {
    int k, sm_mx = 0, sm_mn = 0;
    fg = 1;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
    }
    for (i = 1; i <= m; i++) {
      int mx = -1;
      for (j = 1; j <= n; j++) {
        if (mx < a[j]) mx = a[j], k = j;
      }
      sm_mx += a[k];
      a[k]--;
    }
    for (i = 1; i <= m; i++) {
      int mn = (1 << 30) - 1;
      for (j = 1; j <= n; j++) {
        if (mn > b[j] && b[j]) mn = b[j], k = j;
      }
      sm_mn += b[k];
      b[k]--;
    }
    cout << sm_mx << " " << sm_mn << endl;
  }
  return 0;
}
