#include <bits/stdc++.h>
using namespace std;
const int nax = 2000 + 2;
int dp[nax][nax];
int n, h, l, r;
bool sorter2(const pair<long int, long int> &a,
             const pair<long int, long int> &b) {
  return (a.second < b.second);
}
void print_table(int t) {
  for (int i = 0; i < h;) {
    cout << dp[t][i] << " ";
    i++;
    if ((i % 8 == 0)) cout << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> h >> l >> r;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int v1, v2;
  int t1, t2;
  int r1, r2;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < h; j++) {
      r1 = 0;
      t1 = (j + a[i] - 1 + h) % h;
      v1 = dp[i + 1][t1];
      if ((t1 >= l) && ((t1 + h) % h <= r)) {
        r1 = 1;
      }
      v1 += r1;
      r2 = 0;
      t2 = (j + a[i] + h) % h;
      v2 = dp[i + 1][t2];
      if ((t2 >= l) && ((t2 + h) % h <= r)) {
        r2 = 1;
      }
      v2 += r2;
      dp[i][j] = max(v1, v2);
    }
  }
  cout << dp[0][0] << endl;
}
