#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vb = vector; using vvb = vector; using vd = vector; using vs = vector; using pii = pair; using pll = pair; using pdd = pair; using vpii = vector; using vpll = vector; using vpdd = vector; const int inf = (1 << 30) - 1; const ll INF = 1LL << 60; //const int MOD = 1000000007; const int MOD = 998244353; int main() { ll n, d, t; cin >> n >> d >> t; vi x(n); map mp; for (int i = 0; i < n; i++) { cin >> x[i]; int m = x[i] % d; if (m < 0) m += d; mp[m].push_back(x[i]); } ll ans = 0; for (auto& [k, v] : mp) { int sz = v.size(); ans += sz; vi diff(sz - 1); map cnt; for (int i = 0; i < sz - 1; i++) { diff[i] = x[i + 1] - x[i]; cnt[diff[i]]++; } ll num = sz; int now = 0; for (auto& [di, c] : cnt) { ll time = (di + d * 2 - 1) / (d * 2); ll tmp = 0; if (time - 1 >= now) { tmp = (min(time - 1, t) - now) * num * 2; if (time - 1 < t) { if ((di / d) % 2 == 0) { tmp += num * 2 - c; } else { tmp += num * 2 - (c * 2); } } } ans += tmp; now = time; num -= c; if (time > t) break; } if (now < t) { ans += num * 2 * (t - now); } } cout << ans << endl; return 0; }