#include <bits/stdc++.h>
using namespace std;
long long h, l, r;
long long dp[2001][2001];
bool isGood(long long time) { return (time >= l && time <= r); }
long long rec(long long index, long long prevHr, std::vector<long long> &v) {
  if (index == v.size()) {
    return 0;
  }
  if (dp[index][prevHr] != -1) return dp[index][prevHr];
  long long currTimeOne = (prevHr + v[index]) % h;
  long long currTimeTwo = (prevHr + v[index] - 1) % h;
  long long ans =
      max((isGood(currTimeTwo) ? 1 : 0) + rec(index + 1, currTimeTwo, v),
          (isGood(currTimeOne) ? 1 : 0) + rec(index + 1, currTimeOne, v));
  return dp[index][prevHr] = ans;
}
int32_t main() {
  long long n;
  cin >> n >> h >> l >> r;
  std::vector<long long> v(n);
  for (auto &x : v) cin >> x;
  memset(dp, -1, sizeof(dp));
  long long ans = rec(0, 0, v);
  cout << ans << "\n";
}
