#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
int main() {
  int n, h, l, r;
  scanf(" %d %d %d %d", &n, &h, &l, &r);
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) scanf(" %d", &a[i]);
  vector<int> dp(h, -n);
  dp[0] = 0;
  for (int i = 0; i < (int)(n); ++i) {
    vector<int> nx(h, -n);
    for (int j = 0; j < (int)(h); ++j)
      for (int k : {-1, 0}) {
        int nj = (j + a[i] + k) % h;
        nx[nj] = max(nx[nj], dp[j] + (l <= nj && nj <= r));
      }
    swap(dp, nx);
  }
  int ans = 0;
  for (int i = 0; i < (int)(h); ++i) ans = max(ans, dp[i]);
  printf("%d\n", ans);
  return 0;
}
