#include <bits/stdc++.h>
int faster_in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -faster_in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
using namespace std;
const int INF = int(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);
int n, h, l, r;
int a[2010], dp[2010][2010];
bool isGood(int hora) { return hora >= l && hora <= r; }
int first(int idx, int hora) {
  if (idx == n) return 0;
  int &res = dp[idx][hora];
  if (res != -1) return res;
  res = 0;
  res = first(idx + 1, (hora + a[idx] + h) % h) + isGood((hora + a[idx]) % h);
  res = max(res, first(idx + 1, (hora + a[idx] - 1 + h) % h) +
                     isGood((hora + a[idx] - 1) % h));
  return res;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, (-1), sizeof(dp));
  cin >> n >> h >> l >> r;
  for (int i = (int)0; i < (int)n; i++) {
    cin >> a[i];
  }
  cout << first(0, 0) << endl;
  return 0;
}
