#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(12);
  solve();
  return 0;
}
template <typename T>
void sc(T& x) {
  cin >> x;
}
template <typename Head, typename... Tail>
void sc(Head& head, Tail&... tail) {
  cin >> head;
  sc(tail...);
}
template <typename T>
void pr(const T& x) {
  cout << x << '\n';
}
template <typename Head, typename... Tail>
void pr(const Head& head, const Tail&... tail) {
  cout << head << ' ';
  pr(tail...);
}
const int MAX_SUM = 5e5 + 10;
bool vis[MAX_SUM];
void solve() {
  fill(vis, vis + MAX_SUM, false);
  int n, d;
  sc(n, d);
  vector<int> oks;
  oks.push_back(0);
  for (int i = 0; i < n; i++) {
    int x;
    sc(x);
    for (int j = ((int)oks.size()) - 1; j >= 0; j--) {
      if (x + oks[j] < MAX_SUM && !vis[x + oks[j]]) {
        oks.push_back(x + oks[j]);
        vis[x + oks[j]] = true;
      }
    }
  }
  sort(oks.begin(), oks.end());
  int ans = 0, cur = 0;
  while (true) {
    int idx = upper_bound(oks.begin(), oks.end(), oks[cur] + d) - oks.begin();
    if (oks[idx] != cur + d) {
      idx--;
    }
    if (idx >= ((int)oks.size()) || idx == cur) {
      break;
    }
    ans++;
    cur = idx;
  }
  pr(oks[cur], ans);
}
