#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll base = 1e9+7;
const int maxn = 25010;

int n,k,m,a[maxn],nxt[maxn],prv[maxn],been[maxn];
ll tot,f[maxn][410],g[maxn][410];

ll pw(ll a,ll n) {
    if (n==0) return 1ll;
    if (n==1) return a;
    ll tmp = pw(a,n/2);
    tmp = (tmp*tmp)%base;
    if (n%2==0) return tmp;
    return (tmp*a)%base;
}

int main() {
  //  freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>k>>m;
    for (int i=1;i<=m;i++) cin>>a[i];
    tot = 1ll*(n-m+1) * pw(k,n-m) % base; // A in all seq = (n-m+1) * k^(n-m)
    for (int i=1;i<=m;i++) {
        if (been[a[i]] != 0) prv[i] = been[a[i]];
        been[a[i]]=i;
    }
    memset(been,0,sizeof(been));
    for (int i=m;i>=1;i--) {
        if (been[a[i]] != 0) nxt[i] = been[a[i]];
        been[a[i]]=i;
    }
    bool ok = false;
    int len;
    for (int i=1;i<=m;i++) {
        len = max(len,prv[i]);
        if (i - len >=k) {
            ok = true;
            break;
        }
    }
    if (ok) cout<<tot<<endl; // A is colorful
    else {
        int cnt=0;
            for (int i=1;i<=m;i++) {
                if (prv[i]!=0) break;
                cnt++;
            }
        if (cnt == m) { // A is pairwise distrinc
           // cout<<"lol"<<endl;
            f[0][0] = 1; // f[i][j] = number of non-colorful length i with j last number pairwise distrinc
            for (int i=1;i<=n;i++) {
                ll s=0,t=0;
                for (int j=k-1;j>=1;j--) {
                    s = (s + f[i-1][j]) % base;
                    t = (t + g[i-1][j]) % base;
                    f[i][j] = (f[i-1][j-1] * 1ll*(k-j+1)) % base;
                    g[i][j] = (g[i-1][j-1] * 1ll*(k-j+1)) % base;
                    f[i][j] = (f[i][j] + s) % base;
                    g[i][j] = (g[i][j] + t) % base;
                    if (j>=m) g[i][j] = (g[i][j] + f[i][j]) % base; // g[i][j] = sum(f[i'][j']) with j'>=m,i'<=i
                }
            }

            ll ans = 0;
            for (int i=1;i<k;i++) ans = (ans + g[n][i])%base;
            // each case with >= M number pairwise distrinc will change to arr A. And it duplicate P(k,m) = m! / (m-k)!
            ll sk=1ll, sn=1ll;
            for (int i=1;i<=k;i++) sn = (sn*1ll*i)%base;
            for (int i=1;i<=k-m;i++) sk = (sk*1ll*i)%base;
            ll tmp = sk * pw(sn,base-2) % base;
            ans = ans * tmp % base;
           // cout<<tot<<" "<<ans<<" "<<tmp<<endl;
            cout<<(tot + base - ans ) % base<<endl;
        } else {
            //cout<<"lol"<<endl;
            int u=0,v=0;
            for (int i=1;i<=m;i++) {
                if (prv[i]!=0) break;
                u++;
            }
            for (int i=m;i>=1;i--) {
                if (nxt[i]!=0) break;
                v++;
            }
            f[0][u] = 1; // F[i][j] = number of array with i+u elements and j+u last number pairwise distrinc.
            g[0][v] = 1; // G[i][j] = number of array with n-m-i+v elements and j+v last number pairwise distrinc.
            for (int i=1;i<=n;i++) {
                ll s=0,t=0;
                for (int j=k-1;j>=1;j--) {
                    s = (s + f[i-1][j]) % base;
                    t = (t + g[i-1][j]) % base;
                    f[i][j] = (f[i-1][j-1] * 1ll*(k-j+1)) % base;
                    g[i][j] = (g[i-1][j-1] * 1ll*(k-j+1)) % base;
                    f[i][j] = (f[i][j] + s) % base;
                    g[i][j] = (g[i][j] + t) % base;
                }
            }
            for (int i=0;i<=n-m;i++) {
                ll s=0,t=0;
                for (int j=1;j<k;j++) {
                    s = (s + f[i][j])%base;
                    t = (t + g[n-m-i][j])%base;
                }
                tot = (tot - s*t%base + base) % base;
            }
            cout<<tot<<endl;
        }
    }
}


Measured memory_bytes: 160896