#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, l, h, r, i, j;
  cin >> n >> h >> l >> r;
  long long arr[n + 1];
  for (i = 1; i <= n; i++) cin >> arr[i];
  long long dp[n + 1][h + 1];
  long long poss[n + 1][h + 1];
  memset(poss, 0, sizeof poss);
  memset(dp, 0, sizeof dp);
  poss[0][0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < h; j++) {
      long long prev = (j - arr[i] + h) % h;
      if (poss[i - 1][prev]) {
        poss[i][j] = 1;
        long long ex = 0;
        if (j >= l && j <= r) ex = 1;
        dp[i][j] = max(dp[i][j], dp[i - 1][prev] + ex);
      }
      prev = (j - arr[i] + 1 + h) % h;
      if (poss[i - 1][prev]) {
        poss[i][j] = 1;
        long long ex = 0;
        if (j >= l && j <= r) ex = 1;
        dp[i][j] = max(dp[i][j], dp[i - 1][prev] + ex);
      }
    }
  }
  long long ans = 0;
  for (i = 0; i < h; i++) ans = max(ans, dp[n][i]);
  cout << ans << "\n";
  return 0;
}
