#include <bits/stdc++.h>
using namespace std;
inline void relax(int &dp, int x) {
  if (dp < x) {
    dp = x;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, h, l, r;
  cin >> n >> h >> l >> r;
  vector<vector<int>> dp(n + 1, vector<int>(h, -1));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    for (int j = 0; j < h; j++) {
      if (dp[i][j] != -1) {
        int x = dp[i][j];
        if (l <= (j + val) % h && (j + val) % h <= r) {
          x++;
        }
        relax(dp[i + 1][(j + val) % h], x);
      }
    }
    val--;
    for (int j = 0; j < h; j++) {
      if (dp[i][j] != -1) {
        int x = dp[i][j];
        if (l <= (j + val) % h && (j + val) % h <= r) {
          x++;
        }
        relax(dp[i + 1][(j + val) % h], x);
      }
    }
  }
  cout << *max_element(dp[n].begin(), dp[n].end());
  return 0;
}
