#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, h, l, r;
  cin >> n >> h >> l >> r;
  vector<long long int> a(n + 1, 0);
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  long long int dp[n + 1][h + 1];
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = 0; j <= h; j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j < h; j++) {
      if (dp[i - 1][j] == -1) continue;
      if (((j + a[i] - 1) % h) >= l && ((j + a[i] - 1) % h) <= r)
        dp[i][(j + a[i] - 1) % h] =
            max(dp[i][(j + a[i] - 1) % h], dp[i - 1][j] + 1);
      else
        dp[i][(j + a[i] - 1) % h] =
            max(dp[i][(j + a[i] - 1) % h], dp[i - 1][j]);
      if (((j + a[i]) % h) >= l && ((j + a[i]) % h) <= r)
        dp[i][(j + a[i]) % h] = max(dp[i][(j + a[i]) % h], dp[i - 1][j] + 1);
      else
        dp[i][(j + a[i]) % h] = max(dp[i][(j + a[i]) % h], dp[i - 1][j]);
    }
  }
  long long int ans = 0;
  for (long long int j = 0; j <= h; j++) {
    ans = max(ans, dp[n][j]);
  }
  cout << ans << "\n";
}
