#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int n;
int h;
int l;
int r;
int a[N];
int mem[N][N];
int yes(int x) {
  x %= h;
  return (l <= x) && (x <= r);
}
int go(int idx, int tim) {
  if (idx == n + 1) return 0;
  if (~mem[idx][tim]) return mem[idx][tim];
  int hr = (tim + a[idx] - 1) % h;
  int mx = go(idx + 1, hr) + yes(hr);
  hr = (tim + a[idx]) % h;
  mx = max(mx, go(idx + 1, hr) + yes(hr));
  return mem[idx][tim] = mx;
}
int main() {
  cin >> n >> h >> l >> r;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(mem, -1, sizeof mem);
  cout << go(1, 0);
}
