#include <bits/stdc++.h>
using namespace std;
int n, h, l, r, a[2000 + 10];
int dp[2000 + 10][2000 + 10];
int check(int x) {
  if (x <= r && x >= l)
    return 1;
  else
    return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> h >> l >> r;
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < h; j++) {
      if (dp[i - 1][j] != -1) {
        dp[i][(j + a[i] - 1 + h) % h] =
            max(dp[i - 1][j] + check((j + a[i] - 1 + h) % h),
                dp[i][(j + a[i] - 1 + h) % h]);
        dp[i][(j + a[i] + h) % h] =
            max(dp[i - 1][j] + check((j + a[i] + h) % h),
                dp[i][(j + a[i] + h) % h]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < h; i++) ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}
