
using namespace std;

#define visual

#ifdef visual
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>
#endif
#ifndef visual
#include <bits/stdc++.h>
#endif

typedef long long ll;


template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt& operator+=(const ModInt& p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator-=(const ModInt& p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt& operator*=(const ModInt& p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt& operator/=(const ModInt& p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt& p) const { return x == p.x; }

    bool operator!=(const ModInt& p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream& operator<<(ostream& os, const ModInt& p) {
        return os << p.x;
    }

    friend istream& operator>>(istream& is, ModInt& a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt< 998244353 >;



struct segt {

	struct node {
		mint t, mx, lazyby, lazyto, num, ex, lazytimes;
		ll length, s, e;
		bool set;
		node* l;
		node* r;
	};

	node* rt;

	void build(int i, int j, node* v) {
		v->mx = v->t = v->lazyby = v->lazyto = 0;
		v->length = j - i + 1;
		v->num = 0;
		v->lazytimes = 1;
		v->ex = 0;
		v->s = i;
		v->e = j;
		if (i == j) return;
		v->l = new node();
		v->r = new node();
		build(i, (i + j) / 2, v->l);
		build((i + j) / 2 + 1, j, v->r);
	}

	segt() {}
	segt(int n) {
		rt = new node();
		build(0, n - 1, rt);
	}

	inline void prop(node* v) {
		if (v->l != nullptr) {

			v->l->lazytimes *= v->lazytimes;
			v->r->lazytimes *= v->lazytimes;

		}
		v->ex *= v->lazytimes;
		v->lazytimes = 1;
	}

	void update(int i, int j, mint val, bool prod, node* v) {
		if (j < v->s || v->e < i) return;
		if (i <= v->s && v->e <= j) {
			prop(v);
			if (prod) v->lazytimes *= val;
			else {
				v->num = 1;
				v->ex = val;
			}
			prop(v);
			return;
		}
		prop(v);
		update(i, j, val, prod, v->l);
		update(i, j, val, prod, v->r);
		prop(v->l);
		prop(v->r);
		v->num = v->l->num + v->r->num;
		v->ex = v->l->ex + v->r->ex;

	}

	void updateprod(int i, int j, mint val) { update(i, j, val, true, rt); }
	void updateonce(int i, int j, mint val) { update(i, j, val, false, rt); }


	mint query(int i, int j, bool nums, node* v) {
		if (j < v->s || v->e < i) {

			return 0;
		}
		prop(v);
		if (i <= v->s && v->e <= j) {
			if (nums) return v->num;
			return v->ex;
		}
		mint l = query(i, j, nums, v->l);
		mint r = query(i, j, nums, v->r);
		return l + r;
	}

	mint querynum(int i, int j) { return query(i, j, true, rt); }
	mint queryex(int i, int j) { return query(i, j, false, rt); }
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	segt s(n+1);

	mint ans;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		
		if (i >= k) {
			s.updateprod(0, n, ((mint)(k-1))/k);
		}
		ans += s.queryex(1, x - 1);
		ans += s.querynum(x + 1, n) - s.queryex(x + 1, n);
		s.updateonce(x, x, ((mint)1)/2);
	}
	cout << ans << endl;




}
