#include using namespace std; using ll = long long; const int inf = 1 << 30; const ll INF = 1LL << 60; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; #define rep(i, s, t) for (ll i = (ll)s; i < (ll)(t); i++) #define rrep(i, s, t) for (ll i = (ll)(t) - 1; i >= (ll)(s); i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmin(T1& x, T2 y) { return x > y ? (x = y, true) : false; } template bool chmax(T1& x, T2 y) { return x < y ? (x = y, true) : false; } template using min_heap = priority_queue, greater>; template using max_heap = priority_queue; #include using mint = atcoder::modint998244353; void solve() { int N, M; ll K; cin >> N >> M >> K; vector A(N); rep(i, 0, N) cin >> A[i]; sort(all(A)); vector L(N, inf), R(N, -inf); rep(i, 0, N) rep(j, i, N) { if (A[j] - A[i] <= K) { chmin(L[j], i); chmax(R[i], j); } } vector dp(N + 1); rep(i, 0, N + 1) dp[i] = i; rep(i, 1, M) { vector nxt(N + 1); rep(j, 0, N) { nxt[j + 1] = dp[R[j] + 1] - dp[L[j]]; } rep(j, 0, N) nxt[j + 1] += nxt[j]; swap(dp, nxt); } mint ans = dp[N]; cout << ans.val() << "\n"; } int main() { cin.tie(0)->sync_with_stdio(0); cout << fixed << setprecision(15); srand(time(NULL)); int T; // cin >> T; T = 1; while (T--) solve(); }