#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int n, h, l, r, dp[2222][2222], a[2222];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> h >> l >> r;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < h; i++)
    for (int j = 0; j <= n; j++) dp[j][i] = -1e9;
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < h; j++) {
      int x = j + a[i];
      if (x >= h) x -= h;
      dp[i + 1][x] = max(dp[i + 1][x], dp[i][j] + (l <= x && x <= r));
      int y = j + a[i] - 1;
      if (y >= h) y -= h;
      dp[i + 1][y] = max(dp[i + 1][y], dp[i][j] + (l <= y && y <= r));
    }
  }
  cout << *max_element(dp[n], dp[n] + h);
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;
}
