#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h, l, r;
  cin >> n >> h >> l >> r;
  int a[n];
  for (int x = 0; x < n; x++) cin >> a[x];
  vector<vector<int> > dp(n, vector<int>(h));
  int t1, t2;
  for (int y = 0; y < h; y++) {
    t1 = (y + a[n - 1] - 1) % h;
    t2 = (t1 + 1) % h;
    if ((t1 >= l && t1 <= r) || (t2 >= l && t2 <= r)) {
      dp[n - 1][y] = 1;
    } else
      dp[n - 1][y] = 0;
  }
  if (n == 1) {
    cout << dp[0][0];
    return 0;
  }
  int c1, c2;
  for (int x = n - 2; x >= 0; x--) {
    for (int y = 0; y < h; y++) {
      t1 = (y + a[x] - 1) % h;
      t2 = (t1 + 1) % h;
      c1 = dp[x + 1][t1];
      c2 = dp[x + 1][t2];
      if (t1 >= l && t1 <= r) c1 += 1;
      if (t2 >= l && t2 <= r) c2 += 1;
      dp[x][y] = max(c1, c2);
    }
  }
  cout << dp[0][0];
  return 0;
}
