#include <bits/stdc++.h>
using namespace std;
int dp[2001][2001], arr[2001], n, H, l, r;
int solve(int idx, int h) {
  if (idx == n) return 0;
  if (dp[idx][h] != -1) return dp[idx][h];
  int ans1, ans2 = 0, h1, h2;
  h1 = (h + arr[idx]) % H;
  ans1 = (l <= h1 && h1 <= r) + solve(idx + 1, h1);
  h2 = (h + arr[idx] - 1) % H;
  ans2 = (l <= h2 && h2 <= r) + solve(idx + 1, h2);
  return dp[idx][h] = max(ans1, ans2);
}
int main() {
  scanf("%d %d %d %d", &n, &H, &l, &r);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= H; j++) dp[i][j] = -1;
  int ans = solve(0, 0);
  printf("%d\n", ans);
  return 0;
}
