#include <bits/stdc++.h>
using namespace std;
const int MAX_BUF_SIZE = 16384;
char BUFOR[MAX_BUF_SIZE];
int BUF_SIZE, BUF_POS;
char ZZZ;
int _MINUS;
const int MXN = 2000010;
const int C = 262144;
const int INF = 1000000001;
const int MXS = 500010;
bool knapsack[MXN];
int n, d;
int c[MXN];
priority_queue<pair<int, int> > Q;
int DP[MXN];
void test() {
  scanf("%d %d", &n, &d);
  for (int i = (1); i <= (n); i++) scanf("%d", &c[i]);
  knapsack[0] = 1;
  for (int i = (1); i <= (n); i++)
    for (int j = (MXS); j >= (0); j--)
      if (j - c[i] >= 0 && knapsack[j - c[i]] > 0) knapsack[j] = 1;
  Q.push(make_pair(0, 0));
  int maks = 0, res = 0;
  for (int i = (1); i <= (MXS); i++) {
    if (!knapsack[i]) continue;
    while (!Q.empty()) {
      pair<int, int> p1 = Q.top();
      p1 = make_pair(-p1.first, -p1.second);
      if (p1.second + d < i)
        Q.pop();
      else
        break;
    }
    if (!Q.empty()) {
      pair<int, int> p1 = Q.top();
      p1 = make_pair(-p1.first, -p1.second);
      Q.push(make_pair(-(p1.first + 1), -i));
      maks = p1.first + 1;
      res = i;
    }
  }
  printf("%d %d\n", res, maks);
}
int main() {
  int te = 1;
  while (te--) test();
  return 0;
}
