#include using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v).end() templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> n >> d >> t; vector x(n); vector r; map mp; REP(i,n){ cin >> x[i]; ll rem=(inf*d+x[i])%d; if(!mp.count(rem)){ r.push_back(rem); mp[rem]=r.size()-1; } } int rs=r.size(); vector>> p(rs); REP(i,n){ ll rem=(inf*d+x[i])%d; p[mp[rem]].push_back({x[i]/d-t,x[i]/d+t}); } ll ans=0; REP(i,rs){ sort(ALL(p[i])); ll mi=-INF,ma=-INF-1; for(auto x:p[i]){ if(x.first>ma){ ans+=ma-mi+1; mi=x.first; } chmax(ma,x.second); } ans+=ma-mi+1; } cout << ans << endl; }