#include <iostream>
using namespace std;
int main()
{
int n, p[20], a, b, k, s = 0, num = 0;
cin >> n >> a >> b >> k;
for (int i = 1; i <= n; i++)
{
cin >> p[i];
if (p[i] >= a && p[i] <= b && p[i] % k == 0)
{
s += p[i];
num++;
}
}
cout << s/num;
return 0;
}