#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
int dp[N][N + 1];
int a[N];
int h;
int sub(int a, int b) {
  int res = (a - b) % h;
  if (res < 0) res += h;
  return res;
}
void solve() {
  int n, l, r;
  cin >> n >> h >> l >> r;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i > 0) {
      a[i] = (a[i - 1] + a[i]) % h;
    }
  }
  a[0] = a[0] % h;
  dp[0][0] = l <= a[0] && a[0] <= r;
  dp[0][1] = l <= sub(a[0], 1) && sub(a[0], 1) <= r;
  for (int i = 1; i < n; i++) {
    dp[i][0] = dp[i - 1][0] + (l <= a[i] && a[i] <= r);
    for (int j = 1; j <= i + 1; j++) {
      dp[i][j] =
          max(dp[i - 1][j] + (l <= sub(a[i], j) && sub(a[i], j) <= r),
              dp[i - 1][j - 1] + (l <= sub(a[i], j) && sub(a[i], j) <= r));
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    ans = max(dp[n - 1][i], ans);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  getchar();
  getchar();
}
