#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, h, l, r;
  cin >> n >> h >> l >> r;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  vector<int> dp(h, -1);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    vector<int> dp2(h, -1);
    for (int j = 0; j < h; j++) {
      if (dp[j] < 0) {
        continue;
      }
      int next1 = (j + a[i] - 1) % h;
      int next2 = (j + a[i]) % h;
      int nextValue1 = dp[j];
      int nextValue2 = dp[j];
      if (next1 >= l && next1 <= r) {
        nextValue1++;
      }
      if (next2 >= l && next2 <= r) {
        nextValue2++;
      }
      dp2[next1] = max(dp2[next1], nextValue1);
      dp2[next2] = max(dp2[next2], nextValue2);
    }
    dp = dp2;
  }
  int res = 0;
  for (int i = 0; i < h; i++) {
    res = max(res, dp[i]);
  }
  cout << res << "\n";
}
