#include <bits/stdc++.h>
using namespace std;
int main(int arg, char** argv) {
  int n, h, l, r;
  scanf("%d %d %d %d", &n, &h, &l, &r);
  vector<int> vec(n, 0);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &vec[i]);
  }
  int res = 0;
  vector<int> dp0(h, INT32_MIN);
  dp0[0] = 0;
  for (int i = 0; i < n; ++i) {
    vector<int> dp1(h, INT32_MIN);
    for (int t = 0; t < h; ++t) {
      int next = (t + vec[i]) % h;
      dp1[next] = max(dp1[next], dp0[t] + (next >= l && next <= r));
      res = max(res, dp1[next]);
      next = (t + vec[i] - 1) % h;
      dp1[next] = max(dp1[next], dp0[t] + (next >= l && next <= r));
      res = max(res, dp1[next]);
    }
    dp0 = dp1;
  }
  cout << res << endl;
}
