#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &x, T y) {
  x = x ^ ((x ^ y) & -(x < y));
}
template <class T>
inline void umin(T &x, T y) {
  x = y ^ ((x ^ y) & -(x < y));
}
const int N = 2e5, B = (1 << 30);
int n, m, res, mi, ma;
multiset<int> s1;
multiset<int> s2;
int main() {
  cin >> n >> m;
  for (int i = 1, x; i <= m; i++) cin >> x, s1.insert(x), s2.insert(x);
  for (int i = 1; i <= n; i++) {
    int ppq = *s1.begin();
    mi += ppq;
    s1.erase(s1.find(ppq));
    if (ppq != 1) s1.insert(ppq - 1);
  }
  for (int i = 1; i <= n; i++) {
    auto ppq = s2.end();
    ppq--;
    ma += *ppq;
    s2.erase(s2.find(*ppq));
    if (*ppq != 1) s2.insert(*ppq - 1);
  }
  cout << ma << " " << mi;
  return !1;
}
