#include <bits/stdc++.h>
using namespace std;
int n, a[2005], h, l, r, f[2005][2005], g[2005][2005];
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> h >> l >> r;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  memset(f, -110, sizeof(f));
  memset(g, -110, sizeof(g));
  f[0][0] = g[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < h; ++j) {
      int k = (j - a[i] + h) % h;
      f[i][j] = max(f[i - 1][k], g[i - 1][k]) + (l <= j && r >= j);
      g[i][j] = max(f[i - 1][(k + 1) % h], g[i - 1][(k + 1) % h]) +
                (l <= j && r >= j);
    }
  }
  int ans = 0;
  for (int i = 0; i < h; ++i) ans = max(ans, max(f[n][i], g[n][i]));
  cout << ans;
}
