#include <bits/stdc++.h>
using namespace std;
int A[1001], m;
int getmin(int n, int *a) {
  int ans = 0;
  sort(a, a + m);
  for (int i = 0; i < m; i++) {
    if (n) {
      if (a[i] <= n) {
        n -= a[i];
        ans += a[i] * (a[i] + 1) / 2;
      } else {
        n = a[i] - n;
        ans += a[i] * (a[i] + 1) / 2 - n * (n + 1) / 2;
        break;
      }
    } else
      break;
  }
  return ans;
}
int getmax(int n, int *a) {
  int ans = 0;
  while (n) {
    sort(a, a + m);
    ans += a[m - 1];
    a[m - 1]--;
    n--;
  }
  return ans;
}
int main() {
  int n;
  while (cin >> n >> m) {
    for (int i = 0; i < m; i++) cin >> A[i];
    int mini = getmin(n, A);
    int maxi = getmax(n, A);
    cout << maxi << " " << mini << '\n';
  }
  return 0;
}
