#include <bits/stdc++.h>
using namespace std;
const long long N = 2e3 + 7;
const long long INF = 1e18;
long long n, h, l, r, a[N];
long long dp[N][N];
long long f(long long cur, long long time) {
  if (cur == n + 1) {
    return 0;
  }
  long long &dn = dp[cur][time];
  if (dn != -1) {
    return dn;
  }
  long long nextTime1 = (time + a[cur]) % h,
            nextTime2 = (time + a[cur] - 1) % h;
  return dn = max(f(cur + 1, nextTime1) + (nextTime1 >= l && nextTime1 <= r),
                  f(cur + 1, nextTime2) + (nextTime2 >= l && nextTime2 <= r));
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  memset(dp, -1, sizeof dp);
  cin >> n >> h >> l >> r;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cout << f(1, 0) << '\n';
}
