#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, h, l, r;
  cin >> n >> h >> l >> r;
  int arr[n + 1];
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  int dp[n + 1][n + 1];
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) dp[i][j] = 0;
  }
  dp[1][0] = ((arr[1] % h) <= r and (arr[1] % h) >= l);
  dp[1][1] = (((arr[1] - 1) % h) <= r and ((arr[1] - 1) % h) >= l);
  int sum = arr[1];
  for (int i = 2; i <= n; ++i) {
    sum += arr[i];
    for (int j = 0; j <= i; ++j) {
      if (j <= i - 1)
        dp[i][j] =
            dp[i - 1][j] + (((sum - j) % h) <= r and ((sum - j) % h) >= l);
      if (j > 0)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + (((sum - j) % h) <= r and
                                                     ((sum - j) % h) >= l));
    }
  }
  cout << *max_element(dp[n], dp[n] + n + 1);
}
