#include using namespace std; using ll = long long; using PII = std::pair; using PLL = std::pair; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) PLL divide(ll m, int t) { PLL ret; ret.first = m - t; ret.second = m + t; return ret; } int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; ifstream in("input.txt"); //for debug cin.rdbuf(in.rdbuf()); //for debug #endif int n, d, t, c; ll x, l, r, ans; map mod; vector ameba; cin >> n >> d >> t; c = 0; rep(i, n) { cin >> x; ameba.push_back(x); if (mod[((x % d) + d) % d] == 0) { c++; mod[((x % d) + d) % d] = c; } } // cout << mod.size() << endl; vector ameba2[c]; vector> ameba3[c]; sort(ameba.begin(), ameba.end()); for (auto z : ameba) { if (z >= 0) ameba2[mod[((z % d) + d) % d] - 1].push_back(z / d); else ameba2[mod[((z % d) + d) % d] - 1].push_back((z - d + 1) / d); } rep(i, c) { for (auto z : ameba2[i]) { ameba3[i].push_back(divide(z, t)); } } ans = 0; for (auto y : ameba3) { for (auto i = 0; i < y.size(); i++) { // cout << y[i].first << " " << y[i].second << "\t"; if (i == 0) l = y[i].first, r = y[i].second; else { l = max(r + 1, y[i].first); r = y[i].second; } ans += r - l + 1; } // cout << endl; } cout << ans << endl; return 0; }