#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int64_t INF = (1LL << 60);
const long double pi = acosl((long double)1);
const int64_t mod = 1000000007;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
template <typename T>
class BIT {
 public:
  vector<T> data;
  BIT(int sz) { data.assign(++sz, 0); }
  T sum(int k) {
    T ret = 0;
    for (++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(int k, T x) {
    for (++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int64_t f(vector<int64_t>& v, int64_t x) {
  return lower_bound((v).begin(), (v).end(), x) - v.begin();
}
bool solve() {
  int64_t n, h, l, r;
  cin >> n >> h >> l >> r;
  vector<int64_t> a(n);
  for (int64_t i = 0; i < (int64_t)(n); i++) cin >> a[i];
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(h, -1));
  dp[0][0] = 0;
  for (int64_t i = 0; i < (int64_t)(n); i++) {
    for (int64_t j = 0; j < (int64_t)(h); j++) {
      if (dp[i][j] == -1) continue;
      int64_t next1 = (j + a[i]) % h;
      int64_t count = 0;
      if (l <= next1 and next1 <= r) count++;
      dp[i + 1][next1] = max(dp[i][j] + count, dp[i + 1][next1]);
      next1 = (j + a[i] + h - 1) % h;
      count = 0;
      if (l <= next1 and next1 <= r) count++;
      dp[i + 1][next1] = max(dp[i][j] + count, dp[i + 1][next1]);
    }
  }
  int64_t ans = 0;
  for (int64_t j = 0; j < (int64_t)(h); j++) ans = max(ans, dp[n][j]);
  cout << ans << endl;
  return false;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
