#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
ll n, h, l, r, i;
ll a[2002];
ll dp[2002][2002];
ll fun(ll u, ll v) {
  if (u == n) return 0;
  if (dp[u][v] != -1) return dp[u][v];
  ll ans = 0;
  ll x1 = (v + a[u]) % h;
  ll x2 = (v + a[u] - 1 + h) % h;
  if (x1 >= l && x1 <= r)
    ans = 1 + fun(u + 1, x1);
  else
    ans = fun(u + 1, x1);
  if (x2 >= l && x2 <= r)
    ans = max(ans, 1 + fun(u + 1, x2));
  else
    ans = max(ans, fun(u + 1, x2));
  return dp[u][v] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> h >> l >> r;
  for (i = 0; i < n; i++) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  cout << fun(0, 0);
}
