#include <bits/stdc++.h>
using namespace std;
int n, h, l, r;
int dp[2001][2001];
int a[2001];
int solve(int idx, int time) {
  if (idx == n) return 0;
  int &ret = dp[idx][time];
  if (ret != -1) return ret;
  ret == 0;
  ret =
      max(ret, solve(idx + 1, (time + a[idx]) % h) +
                   (((time + a[idx]) % h) >= l && ((time + a[idx]) % h) <= r));
  ret = max(ret, solve(idx + 1, (time + a[idx] - 1) % h) +
                     (((time + a[idx] - 1) % h) >= l &&
                      ((time + a[idx] - 1) % h) <= r));
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> h >> l >> r;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << solve(0, 0);
  return 0;
}
