#include <bits/stdc++.h>
using namespace std;
const long long INF_ll = 4e18 + 7;
const int INF_int = 1e9 + 7;
int a[2005];
int dp[2002][2002];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, h, l, r, ans = 0;
  cin >> n >> h >> l >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(dp, -1e9 - 7, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < h; j++) {
      int j1 = (j + a[i]) % h, j2 = (j + a[i] - 1) % h;
      int m1 = 0, m2 = 0;
      if (j1 <= r && j1 >= l) m1++;
      if (j2 <= r && j2 >= l) m2++;
      dp[i][j1] = max(dp[i][j1], dp[i - 1][j] + m1);
      dp[i][j2] = max(dp[i][j2], dp[i - 1][j] + m2);
    }
  }
  for (int i = 0; i < h; i++) {
    ans = max(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}
