#include <bits/stdc++.h>
using namespace std;
int n, h, l, r;
vector<int> a;
int memo[2001][2001];
int calc(int i, int hora) {
  if (i == n) return (int)(hora <= r && hora >= l);
  if (memo[i][hora] != -1) return memo[i][hora];
  if (hora <= r && hora >= l && i > 0) {
    return memo[i][hora] = 1 + max(calc(i + 1, (hora + a[i]) % h),
                                   calc(i + 1, (hora + a[i] - 1) % h));
  }
  return memo[i][hora] = max(calc(i + 1, (hora + a[i]) % h),
                             calc(i + 1, (hora + a[i] - 1) % h));
}
int main() {
  cin >> n >> h >> l >> r;
  a.resize(n);
  memset(memo, -1, sizeof memo);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << calc(0, 0) << endl;
}
