#include <bits/stdc++.h>
using namespace std;
int a[1005], i, m, n, mx, mn, k, z;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a[i];
  }
  z = n;
  sort(a, a + m);
  for (i = 0; i < m; i++) {
    if (n < a[i]) {
      mn = mn + ((a[i] + 1) * a[i]) / 2 - (((a[i] - n) + 1) * (a[i] - n)) / 2;
      break;
    } else {
      mn = mn + ((a[i] + 1) * a[i]) / 2;
      n = n - a[i];
    }
  }
  i = m;
  while (z > 0) {
    mx = mx + a[i - 1];
    a[i - 1]--;
    z--;
    sort(a, a + i);
  }
  cout << mx << " " << mn;
}
