#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& a) {
  for (T& ai : a) is >> ai;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> const& a) {
  os << "[ ";
  for (const T& ai : a) os << ai << " ";
  return os << "]";
}
template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& a) {
  return is >> a.first >> a.second;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> const& a) {
  return os << "(" << a.first << ", " << a.second << ")";
}
int f() {
  int n, h, l, r;
  cin >> n >> h >> l >> r;
  vector<int> a(n), b(h, -1);
  cin >> a;
  b[0] = 0;
  for (int ai : a) {
    vector<int> c(h, -1);
    for (int i = 0; i < h; ++i) {
      if (b[i] < 0) continue;
      int j = i + ai - 1;
      if (j >= h) j -= h;
      c[j] = max(c[j], b[i] + (l <= j && j <= r));
      if (++j >= h) j -= h;
      c[j] = max(c[j], b[i] + (l <= j && j <= r));
    }
    b.swap(c);
  }
  return *max_element((b).begin(), (b).end());
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << f() << "\n";
  return 0;
}
