#include #include using namespace std; using ll = long long; using mint = atcoder::modint998244353; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector a(n); for(auto &&v : a) cin >> v; sort(a.begin(), a.end()); vector dp(n + 1, 1); dp[0] = 0; for(int i = 1; i < m; i++){ for(int j = 0; j < n; j++) dp[j + 1] += dp[j]; vector ndp(n + 1); for(int j = 0, l = 0, r = 0; j < n; j++){ while(l < n && a[l] < a[j] - k) l++; while(r < n && a[r] <= a[j] + k) r++; ndp[j + 1] = dp[r] - dp[l]; } swap(dp, ndp); } cout << accumulate(dp.begin(), dp.end(), mint::raw(0)).val() << '\n'; }