#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powmod(long long a, long long b, long long p) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long temp = powmod(a, b / 2, p);
  temp *= temp;
  temp %= p;
  if (b % 2 == 0) return temp;
  temp = temp * a;
  temp %= p;
  return temp;
}
void solve() {
  int n, h, l, r;
  cin >> n >> h >> l >> r;
  int a[n];
  for (__typeof((n)) i = (0); i < (n); i++) cin >> a[i];
  vector<vector<int> > dp(n + 1, vector<int>(h, 0));
  for (__typeof((n - 1)) i = (n - 1); i >= (0); i--) {
    for (__typeof((h)) j = (0); j < (h); j++) {
      int x = (j + a[i]) % h;
      int y = (j + a[i] - 1) % h;
      int c1 = bool(x >= l && x <= r);
      int c2 = bool(y >= l && y <= r);
      dp[i][j] = max(dp[i + 1][x] + c1, dp[i + 1][y] + c2);
    }
  }
  cout << dp[0][0] << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
