local mmi, mma = math.min, math.max local mfl, mce = math.floor, math.ceil local n, d, t = io.read("*n", "*n", "*n") local rem = {} local bias = 1000000007 for i = 1, n do local x = bias + io.read("*n") local r = x % d if not rem[r] then rem[r] = {} end local z = mfl(x / d) table.insert(rem[r], {z - t, z + t}) end local ret = 0 for _u, tbl in pairs(rem) do table.sort(tbl, function(a, b) return a[1] < b[1] end) ret = ret + tbl[1][2] - tbl[1][1] + 1 local right = tbl[1][2] for i = 2, #tbl do local l, r = tbl[i][1], tbl[i][2] l = mma(l, right + 1) ret = ret + mma(0, r - l + 1) right = mma(right, r) end end print(ret)