#include <bits/stdc++.h>   using namespace std;   const int maxN = 2005;   int n, h, l, r, a[maxN];   int dp[maxN][maxN];   inline int getint() {     int num = 0, bj = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c == EOF) return EOF;       bj = (c ==  -  || bj == -1) ? -1 : 1, c = getchar();     }     while (c >=  0  && c <=  9 ) num = num * 10 + c -  0 , c = getchar();     return num * bj;   }   void init() {     cin >> n >> h >> l >> r;     for (int i = 1; i <= n; ++i) {       a[i] = getint();     }   }   int cor(int x) { return (x % h + h) % h; }   void solve() {     memset(dp, -1, sizeof(dp));     int ans = -1;     (a[1] >= l && a[1] <= r)                     ? dp[1][a[1]] = 1,                                ans = max(ans, 1) : dp[1][a[1]] = 0,                                ans = max(ans, 0);     (a[1] - 1 >= l && a[1] - 1 <= r)         ? dp[1][a[1] - 1] = 1,                        ans = max(ans, 1) : dp[1][a[1] - 1] = 0, ans = max(ans, 0);     for (int i = 2; i <= n; ++i) {       for (int j = 0; j < h; ++j) {         if (dp[i - 1][cor(j - a[i])] == -1 && dp[i - 1][cor(j - a[i] + 1)] == -1)           continue;         dp[i][j] = max(dp[i - 1][cor(j - a[i])], dp[i - 1][cor(j - a[i] + 1)]);         if (j >= l && j <= r) dp[i][j]++;         ans = max(ans, dp[i][j]);       }     }     cout << ans << endl;   }   int main() {     init();     solve();   }   