#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 25005, K = 405, MOD = 1e9 + 7;
ll dp[N][K], dp2[N][K], a[N], p[N], fac[N];
bool used[K];

void add(ll &a, ll b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

ll bp(ll a, ll p) {
    ll r = 1;
    while (p > 0) {
        if (p & 1)
            r = r * a % MOD;
        a = a * a % MOD;
        p >>= 1;
    }
    return r;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k, m;
    cin >> n >> k >> m;

    for (int i = 0; i < m; i++) {
        cin >> a[i];
        a[i]--;
    }

    p[0] = 1;
    fac[0] = 1;
    for (int i = 0; i < N - 1; i++) {
        p[i + 1] = p[i] * k % MOD;
        fac[i + 1] = fac[i] * (i + 1) % MOD;
    }

    ll ans = (n - m + 1) * p[n - m] % MOD;

    bool colorful = false;

    for (int i = 0; i <= m - k; i++) {
        fill(used, used + k, 0);
        int x = i;
        while (x < m && !used[a[x]]) {
            used[a[x]] = 1;
            x++;
        }
        if (x - i == k) {
            colorful = true;
            break;
        }
    }

    if (!colorful) {
        fill(used, used + k, 0);
        int lc = 0;
        for (int i = 0; i < m; i++) {
            if (used[a[i]])
                break;
            lc++;
            used[a[i]] = 1;
        }

        fill(used, used + k, 0);
        int rc = 0;
        for (int i = m - 1; i >= 0; i--) {
            if (used[a[i]])
                break;
            rc++;
            used[a[i]] = 1;
        }

        dp[0][0] = 1;

        for (int i = 0; i <= n; i++) {
            for (int j = k - 1; j >= 0; j--) {
                add(dp[i][j], dp[i][j + 1]);                
            }
            for (int j = 1; j < k; j++) {
                add(dp[i + 1][j], dp[i][j]);
                add(dp[i + 1][j], (dp[i][j - 1] - dp[i][j] + MOD) * (k - j + 1) % MOD);
            }
        }

        ll bad = 0;

        if (lc == m) {
            for (int i = 0; i <= n; i++) {
                for (int j = k - 1; j >= m; j--) {
                    add(dp2[i][j], (dp[i][j] - dp[i][j + 1] + MOD) % MOD);
                }
                for (int j = k - 1; j >= 0; j--) {
                    add(dp2[i][j], dp2[i][j + 1]);
                }
                for (int j = 1; j < k; j++) {
                    add(dp2[i + 1][j], dp2[i][j]);
                    add(dp2[i + 1][j], (dp2[i][j - 1] - dp2[i][j] + MOD) * (k - j + 1) % MOD);
                }
            }

            // cout << dp2[4][0] << "\n";

            // cout << dp2[5][0] * bp(fac[k], MOD - 2) % MOD * fac[k - m] % MOD << "\n";

            bad = dp2[n][0];
            bad = bad * bp(fac[k], MOD - 2) % MOD * fac[k - m] % MOD;
        }
        else {
            for (int i = 0; i <= n - m; i++) {
                ll lt = dp[i + lc][lc] * bp(fac[k], MOD - 2) % MOD * fac[k - lc] % MOD,
                    rt = dp[n - m - i + rc][rc] * bp(fac[k], MOD - 2) % MOD * fac[k - rc] % MOD;
                bad = (bad + lt * rt) % MOD;
            }
        }

        // cout << ans << " " << bad << "\n";

        ans = (ans - bad + MOD) % MOD;
    }

    cout << ans;

    return 0;   
}   

Measured memory_bytes: 158848