#include <bits/stdc++.h>
using namespace std;
bool desc(int &a, int &b) { return (a > b); }
bool pairone(pair<long long int, long long int> &a,
             pair<long long int, long long int> &b) {
  return (a.first < b.first);
}
bool good(int, int, int);
int main() {
  int n, h, l, r;
  cin >> n >> h >> l >> r;
  vector<int> vec(n);
  for (auto &it : vec) cin >> it;
  vector<vector<int>> rix(h, vector<int>(n));
  int time1, time2;
  int val1, val2;
  for (int i = 0; i < h; i++) {
    time1 = (i + vec[n - 1]) % h;
    time2 = (i + vec[n - 1] - 1) % h;
    if ((time1 >= l && time1 <= r) || (time2 >= l && time2 <= r))
      rix[i][n - 1] = 1;
  }
  for (int j = n - 2; j >= 0; j--) {
    for (int i = 0; i < h; i++) {
      time1 = (i + vec[j]) % h;
      val1 = (good(time1, l, r) + rix[time1][j + 1]);
      time2 = (i + vec[j] - 1) % h;
      val2 = (good(time2, l, r) + rix[time2][j + 1]);
      rix[i][j] = max(val1, val2);
    }
  }
  cout << rix[0][0];
}
bool good(int t, int l, int r) { return ((t >= l && t <= r) ? 1 : 0); }
