#include <bits/stdc++.h>
using namespace std;
int dp[2005][2005];
int n, h, l, r;
int f(int time, int ind, vector<int> &v) {
  if (ind == v.size()) return 0;
  if (dp[ind][time] != -1) return dp[ind][time];
  int fi = 0, se = 0, t1, t2;
  t1 = (time + v[ind]) % h;
  if (t1 >= l && t1 <= r) fi++;
  fi += f(t1, ind + 1, v);
  t2 = (time + v[ind] - 1) % h;
  if (t2 >= l && t2 <= r) se++;
  se += f(t2, ind + 1, v);
  return dp[ind][time] = max(fi, se);
}
int main() {
  cin >> n >> h >> l >> r;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  memset(dp, -1, sizeof(dp));
  cout << f(0, 0, v) << endl;
}
