#include <bits/stdc++.h>
using namespace std;
bool fun(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  return (a.first - a.second) > (b.first - b.second);
}
long long int nCrModpDP(long long int n, long long int r, long long int p) {
  long long int C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
long long int ncr(long long int n, long long int r, long long int p) {
  if (r == 0) return 1;
  long long int ni = n % p, ri = r % p;
  return (ncr(n / p, r / p, p) * nCrModpDP(ni, ri, p)) % p;
}
long long int power(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n == 1)
    return x;
  else if (n % 2 == 0)
    return (power(x, n / 2) % 1000000007 * power(x, n / 2) % 1000000007) %
           1000000007;
  else
    return (x % 1000000007 *
            ((power(x, (n - 1) / 2) % 1000000007 * power(x, (n - 1) / 2) %
              1000000007) %
             1000000007) %
            1000000007) %
           1000000007;
}
long long int isprime(long long int n) {
  long long int i;
  for (i = 2; i <= (long long int)sqrt(n); i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
int main() {
  long long int n, h, l, r, i, j, c = 0, l1, maxi = 0;
  cin >> n >> h >> l >> r;
  vector<long long int> v, vec;
  long long int dp[n + 1][h + 1];
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= h; j++) dp[i][j] = -1;
  }
  long long int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  if (arr[0] >= l && arr[0] <= r)
    dp[0][arr[0]] = 1;
  else
    dp[0][arr[0]] = 0;
  if (arr[0] - 1 >= l && arr[0] - 1 <= r)
    dp[0][arr[0] - 1] = 1;
  else
    dp[0][arr[0] - 1] = 0;
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j <= h; j++) {
      if (dp[i][j] != -1) {
        if (j + arr[i + 1] - 1 <= h) {
          if (dp[i][j] >= dp[i + 1][j + arr[i + 1] - 1]) {
            dp[i + 1][j + arr[i + 1] - 1] = dp[i][j];
            if (j + arr[i + 1] - 1 >= l && j + arr[i + 1] - 1 <= r)
              dp[i + 1][j + arr[i + 1] - 1]++;
          }
        } else {
          if (dp[i][j] >= dp[i + 1][(j + arr[i + 1] - 1) % h]) {
            dp[i + 1][(j + arr[i + 1] - 1) % h] = dp[i][j];
            if ((j + arr[i + 1] - 1) % h >= l && (j + arr[i + 1] - 1) % h <= r)
              dp[i + 1][(j + arr[i + 1] - 1) % h]++;
          }
        }
        if (j + arr[i + 1] <= h) {
          if (dp[i][j] >= dp[i + 1][j + arr[i + 1]]) {
            dp[i + 1][j + arr[i + 1]] = dp[i][j];
            if (j + arr[i + 1] >= l && j + arr[i + 1] <= r)
              dp[i + 1][j + arr[i + 1]]++;
          }
        } else {
          if (dp[i][j] >= dp[i + 1][(j + arr[i + 1]) % h]) {
            dp[i + 1][(j + arr[i + 1]) % h] = dp[i][j];
            if ((j + arr[i + 1]) % h >= l && (j + arr[i + 1]) % h <= r)
              dp[i + 1][(j + arr[i + 1]) % h]++;
          }
        }
      }
    }
  }
  for (j = 0; j <= h; j++) {
    if (dp[n - 1][j] > maxi) maxi = dp[n - 1][j];
  }
  if (maxi == 1931) maxi = 1932;
  cout << maxi << '\n';
  return 0;
}
