#include using namespace std; #define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++) #define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++) #define all(n) (n).begin(),(n).end() typedef vector Vi; typedef vector VVi; typedef pair Pii; typedef vector VPii; int main(){ map> group; int N,D,T; cin >> N >> D >> T; rep(i,N){ long long X; cin >> X; X += 1000000000ll; group[X%D].push_back((X-X%D)/D); } long long allTot = 0; for( auto g : group ){ vector seg; for( auto i : g.second ){ seg.push_back({i-T,i+T+1}); } sort(all(seg)); Pii nowSeg = seg[0]; long long tot = 0; for(int i = 1 ; i < seg.size() ; i++){ if( nowSeg.second < seg[i].first ){ tot += nowSeg.second - nowSeg.first; nowSeg = seg[i]; }else{ nowSeg.second = max(nowSeg.second,seg[i].second); } } tot += nowSeg.second - nowSeg.first; allTot += tot; } cout << allTot << endl; }