#define _USE_MATH_DEFINES #include #include #include #include #include //#include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(10);// int N,D,T; cin>>N>>D>>T; int X[100]; rep(i,N){ cin>>X[i]; } ////// int t[100]; int tCount = 0; int tNo,tNoi,Len; vector v[100]; rep(i,N){ if( X[i] >= 0 ){ tNoi = X[i]%D; Len = X[i]/D; }else{ tNoi = D+X[i]%D; Len = (X[i]-X[i]%D)/D -1; } for(tNo=0;tNo= tCount){ t[tCount] = tNoi; ++tCount; } v[tNo].push_back( PII(Len,Len) ); } rep(i,tCount){ sort( v[i].begin(),v[i].end() ); } rep(i,tCount){ vector::iterator itr = v[i].begin(); while((itr+1) != v[i].end() ){ if( ( (itr+1)->first - itr->second )/2 <= T ){ itr->second = (itr+1)->second; v[i].erase(itr+1); }else{ ++itr; } } } LL ans = 0; rep(i,tCount){ vector::iterator itr = v[i].begin(); while( itr != v[i].end() ){ if(itr->first == itr->second){ ans += 2*T+1; }else{ ans += itr->second - itr->first + 1 + 2*T; } ++itr; } } P(ans); return 0; }