#include <bits/stdc++.h>
using namespace std;
int Set(int mask, int pos) { return mask = mask | (1 << pos); }
bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }
int dp[2005][2005], l, r, n, h;
int arr[2005];
int solve(int pos, int hour) {
  if (pos == n) {
    if (hour >= l && hour <= r) return 1;
    return 0;
  }
  if (dp[pos][hour] != -1) return dp[pos][hour];
  int ret =
      (hour >= l && hour <= r) + solve(pos + 1, (hour + arr[pos] - 1) % h);
  ret = max(ret,
            (hour >= l && hour <= r) + solve(pos + 1, (hour + arr[pos]) % h));
  return dp[pos][hour] = ret;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> h >> l >> r;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  memset(dp, -1, sizeof(dp));
  int res = solve(0, 0);
  if (l == 0) res--;
  cout << res << endl;
  return 0;
}
