#include <bits/stdc++.h>
using namespace std;
int n, h, l, r;
int dp[2005][2005];
vector<int> times;
int solve(int pos, int time) {
  if (pos == n) {
    if (time >= l && time <= r)
      return 1;
    else
      return 0;
  }
  if (dp[pos][time] != -1) return dp[pos][time];
  int sleepT1 = (time + times[pos]) % h;
  int sleepT2 = (time + times[pos] - 1) % h;
  int a = solve(pos + 1, sleepT1);
  int b = solve(pos + 1, sleepT2);
  if (pos > 0 && time >= l && time <= r) a++, b++;
  dp[pos][time] = max(a, b);
  return dp[pos][time];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, -1, sizeof(dp));
  cin >> n >> h >> l >> r;
  int t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    times.push_back(t);
  }
  int ans = solve(0, 0);
  cout << ans << "\n";
}
