#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX_N = 25052, MAX_M = 404;
const ll MOD = 1e9 + 7;

ll sq(ll x) { return x * x % MOD; }
ll qpow(ll a, ll b) { return b ? sq(qpow(a, b / 2)) * (b & 1 ? a : 1) % MOD : 1; }
ll inv(ll x) { return qpow(x, MOD - 2); }

int N, M, K, A[MAX_N], A_prev[MAX_N];

int init() {
    scanf("%d%d%d", &N, &M, &K);
    for (int i = 1; i <= K; i++) scanf("%d", &A[i]);
    int last_occur[MAX_M]; memset(last_occur, 0, sizeof(last_occur));
    for (int i = 1; i <= K; i++) {
        A_prev[i] = last_occur[A[i]];
        last_occur[A[i]] = i;
    }
    for (int i = M; i <= K; i++) {
        bool succ = true;
        for (int j = i; j > i - M; j--) {
            if (A_prev[j] > i - M) {
                succ = false;
            }
        }
        if (succ)
            return 1;
    }
    for (int i = 1; i <= K; i++) {
        if (A_prev[i]) {
            return 2;
        }
    }
    return 3;
}

ll F[MAX_N][MAX_M], G[MAX_N][MAX_M];

void clear() {
    memset(F, 0, sizeof(F));
    memset(G, 0, sizeof(G));
}

void calc_FG(bool disable_M) {
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++)
            (F[i][j] += F[i - 1][j]) %= MOD;
        for (int j = M - 1; j; j--)
            (F[i][j] += F[i][j + 1]) %= MOD;
        for (int j = 1; j <= M; j++)
            (F[i][j] += F[i - 1][j - 1] * (M - j + 1)) %= MOD;
        for (int j = 1; j <= M; j++)
            (G[i][j] += G[i - 1][j]) %= MOD;
        for (int j = M - 1; j; j--)
            (G[i][j] += G[i][j + 1]) %= MOD;
        for (int j = 1; j <= M; j++)
            (G[i][j] += G[i - 1][j - 1] * (M - j + 1)) %= MOD;
        for (int j = K; j <= M; j++)
            (G[i][j] += F[i][j]) %= MOD;
        if (disable_M) F[i][M] = G[i][M] = 0;
    }
}

void solve1() {
    ll ans = (N - K + 1) * qpow(M, N - K) % MOD;
    printf("%lld\n", ans);
}

void solve2() {
    int pre_len = 0, suf_len = K;
    for (int i = 1; i <= K; i++) {
        if (A_prev[i]) break;
        pre_len = i;
    }
    for (int i = K; i; i--)
        suf_len = min(suf_len, K - A_prev[i]);
    ll H_pre[MAX_N], H_suf[MAX_N];
    memset(H_pre, 0, sizeof(H_pre));
    memset(H_suf, 0, sizeof(H_suf));
    F[0][pre_len] = 1;
    calc_FG(true);
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            (H_pre[i] += F[i][j]) %= MOD;
        }
    }
    clear();
    F[0][suf_len] = 1;
    calc_FG(true);
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            (H_suf[i] += F[i][j]) %= MOD;
        }
    }
    clear();
    ll ans = 0;
    for (int i = 0; i <= N - K; i++) {
        (ans += qpow(M, N - K) - H_pre[i] * H_suf[N - K - i] % MOD + MOD) %= MOD;
    }
    printf("%lld\n", ans);
}

void solve3() {
    F[0][0] = 1;
    calc_FG(false);
    ll ans = 0;
    for (int i = 0; i <= M; i++)
        (ans += G[N][i]) %= MOD;
    clear();
    F[0][0] = 1;
    calc_FG(true);
    for (int i = 0; i <= M; i++)
        (ans += MOD - G[N][i]) %= MOD;
    clear();
    ll fac[MAX_M];
    fac[0] = 1;
    for (int i = 1; i <= M; i++) fac[i] = fac[i - 1] * i % MOD;
    (ans *= fac[M - K] * inv(fac[M]) % MOD) %= MOD;
    printf("%lld\n", ans);
}

int main() {
    switch (init()) {
        // 1 : contain
        case 1:
        solve1(); break;
        // 2 : split
        case 2:
        solve2(); break;
        // 3 : part
        case 3:
        solve3(); break;
    }
}


Measured memory_bytes: 158976