#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 2e5 + 5, md = 998244353;

inline int add(int x, int y) {
    x += y;
    if (x >= md) x -= md;
    return x;
}

inline int sub(int x, int y) {
    x -= y;
    if (x < 0) x += md;
    return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

inline int fpow(int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        y >>= 1; x = mul(x, x);
    }
    return ans;
}

int a[N], id[N], s[N];
int n, k, p, ans;

bool cmp(int x, int y) { return a[x] < a[y]; }

struct fenwick {
    int f[N];

    inline int lowbit(int x) { return x & -x; }

    inline void add(int x, int y) {
        while (x <= n) {
            f[x] = ::add(f[x], y);
            x += lowbit(x);
        }
    }

    inline int query(int x) {
        int ans = 0;
        while (x) {
            ans = ::add(ans, f[x]);
            x ^= lowbit(x);
        }
        return ans;
    }
} tr1, tr2;

int main() {
    read(n); read(k); p = mul(k - 1, fpow(k, md - 2));
    for (int i = 1; i <= n; i++) read(a[i]), id[i] = i;
    for (int i = 1; i <= n; i++) s[i] = add(s[i - 1], fpow(p, max(i, k)));
    sort(id + 1, id + n + 1, cmp);
    for (int i = 1; i <= n; i++) {
        int p1 = sub(tr1.query(n), tr1.query(id[i])), p2 = sub(sub(s[n], s[id[i]]), p1), inv = fpow(fpow(p, max(id[i], k)), md - 2);
        p1 = mul(p1, inv); p2 = mul(p2, inv);
        ans = add(ans, sub(tr2.query(n) - tr2.query(id[i]), p1));
        ans = add(ans, mul(add(p1, p2), (md + 1) >> 1));
        tr1.add(id[i], fpow(p, max(id[i], k))); tr2.add(id[i], 1);
    }
    print(ans, '\n');
    return 0;
}