#include <bits/stdc++.h>
using namespace std;
long long max(long long i, long long j) { return i > j ? i : j; }
long long min(long long i, long long j) { return i < j ? i : j; }
int hcf(int a, int b) {
  if (b == 0) return a;
  return hcf(b, a % b);
}
int ncr(int n, int r) {
  if (r == 0) return 1;
  if (n == r) return 1;
  if (r == 1) return n;
  return ncr(n - 1, r) + ncr(n - 1, r - 1);
}
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
bool sortValD(pair<int, int> a, pair<int, int> b) {
  return a.second > b.second;
}
vector<int> sieve(int n) {
  vector<bool> prime(n + 1, true);
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  vector<int> v;
  for (int i = 2; i < prime.size() + 2; i++) {
    if (prime[i]) v.push_back(i);
  }
  return v;
}
int main() {
  long long n, h, l, r;
  cin >> n >> h >> l >> r;
  vector<long long> a(n, 0);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(h, 0));
  for (long long i = n - 1; i >= 0; i--) {
    for (long long j = 0; j < h; j++) {
      long long x = (j + a[i]) % h;
      long long y = (j + a[i] - 1) % h;
      int A = 0, B = 0;
      if (x >= l && x <= r) A = 1;
      if (y >= l && y <= r) B = 1;
      dp[i][j] = max(dp[i + 1][x] + A, dp[i + 1][y] + B);
    }
  }
  cout << dp[0][0] << endl;
}
