#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, h, l, r, temp;
  cin >> n >> h >> l >> r;
  int ar[n + 1];
  for (int i = 1; i <= n; i++) cin >> ar[i];
  int dp[n + 1][h + 1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= h; j++) dp[i][j] = -1;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= h; j++) {
      if (dp[i - 1][j] == -1)
        continue;
      else {
        temp = (j + ar[i]) % h;
        if (temp >= l && temp <= r && dp[i - 1][j] + 1 > dp[i][temp])
          dp[i][temp] = dp[i - 1][j] + 1;
        else if (dp[i - 1][j] > dp[i][temp])
          dp[i][temp] = dp[i - 1][j];
        temp = (j + ar[i] - 1) % h;
        if (temp >= l && temp <= r && dp[i - 1][j] + 1 > dp[i][temp])
          dp[i][temp] = dp[i - 1][j] + 1;
        else if (dp[i - 1][j] > dp[i][temp])
          dp[i][temp] = dp[i - 1][j];
      }
    }
  }
  int max = 0;
  for (int i = 0; i <= h; i++) {
    if (dp[n][i] > max) max = dp[n][i];
  }
  cout << max;
  return 0;
}
