#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int mem[2005][2005], n, h, l, r;
int arr[2005];
int f(int inx, int hour) {
  if (inx >= n) return 0;
  if (mem[inx][hour] != -1) return mem[inx][hour];
  int a = f(inx + 1, (hour + arr[inx]) % h);
  int b = f(inx + 1, (hour + arr[inx] - 1) % h);
  if ((hour + arr[inx]) % h >= l && (hour + arr[inx]) % h <= r) ++a;
  if ((hour + arr[inx] - 1) % h >= l && (hour + arr[inx] - 1) % h <= r) {
    ++b;
  }
  return mem[inx][hour] = max(a, b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> h >> l >> r;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  memset(mem, -1, sizeof mem);
  cout << f(0, 0) << endl;
  return 0;
}
