#include <bits/stdc++.h>
using namespace std;
const long long int MOD = (long long int)1e9 + 7;
long long int n, h, l, r;
vector<long long int> a;
long long int mp[2005][2005];
long long int dp(long long int day, long long int time) {
  time %= h;
  if (mp[day][time] != -1) {
    return mp[day][time];
  }
  long long int t1 = time + a[day] - 1;
  long long int t2 = time + a[day];
  t1 %= h;
  t2 %= h;
  if (day >= n - 1) {
    if ((t1 <= r && t1 >= l) || (t2 <= r && t2 >= l)) {
      return 1;
    }
    return 0;
  }
  long long int ans1 = 0, ans2 = 0;
  if (t1 <= r && t1 >= l) {
    ans1 = 1;
  }
  if (t2 <= r && t2 >= l) {
    ans2 = 1;
  }
  ans1 += dp(day + 1, t1);
  ans2 += dp(day + 1, t2);
  return mp[day][time] = max(ans1, ans2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    long long int x, ans = 0, c = 0, sum = 0;
    cin >> n >> h >> l >> r;
    a.resize(n);
    for (long long int(i) = 0; (i) < (n); ++(i)) cin >> a[i];
    memset(mp, -1, sizeof(mp));
    cout << dp(0, 0) << "\n";
  }
}
