#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fill(x,v) memset(x,v,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x <<": " << x << endl
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

const ll MOD = 1e9+7;

vi a, ini, fin;

ll fact[410];
ll dp1[2][410],dp2[2][410], dp3[2][410], dp4[2][410];
set<int> lista;
map<int, int> mapa;

void pre(){
    fact[0]= 1;
    for(int i  = 1; i < 410 ; i++){
        fact[i]= (fact[i-1]*i)%MOD;
    }
}

ll binpow(ll b, ll e){
    if(e == 0) return 1;
    ll aux = binpow(b, e>>1);
    aux = (aux*aux)%MOD;
    if(e&1) aux = (aux*b)%MOD;
    return aux;
}

int main(){
    pre();
    ll n, k, m;
    cin >> n >> k>> m;
    ll total = ((n-m+1)*(binpow(k,n-m)))%MOD;
    a.resize(m);
    rep(i,0,m){
        cin >> a[i];
        //lista.insert(a[i]);
    }
    int caso = 2;
    ll f = k;
    ll b = k;
    bool igual = false;
    for(int i  = 0; i < min(m,k); i++){
        lista.insert(a[i]);
        if(lista.size() != i+1){
            igual = true;
            f = i;
            break;
        }
    }
    lista.clear();
    for(int i  = 0; i < min(m,k); i++){
        lista.insert(a[m-1-i]);
        if(lista.size() != i+1){
            igual = true;
            b = i;
            break;
        }
    }
    bool color = false;
    if(m >= k){
        rep(i,0,k) mapa[a[i]]++;
        ll i = 0;
        ll j = k-1;   
        while(1){
            if(mapa.size() == k){
                color = true;
                break;
            }
            if(j == m-1) break;
            mapa[a[i]]--;
            if(mapa[a[i]] == 0) mapa.erase(a[i]);
            i++;
            j++;
            mapa[a[j]]++;
        }
    }
    //trace(color);
    if(color) caso = 1;
    else if(igual) caso = 3;
    
    if(k > 1) dp1[1][1] = k;
    ll suma1 = dp1[1][1];
    if(m == 1) dp2[1][1] = dp1[1][1];
    ll suma2 = dp2[1][1];
    ll suma3 = 1;
    ll suma4 = 1;
    dp3[m&1][f] = 1;
    dp4[m&1][b] = 1;
    ini.pb(1);
    fin.pb(1);
    ll aux1, aux2, aux3, aux4;
    for(int i = 2; i <= n; i++){
       // trace(i);
        aux1=0;
        aux2=0;
        aux3=0;
        aux4=0;
        for(int j = 1; j < k ; j++){
            if(j > 1){
                suma1 = (suma1 - (dp1[(i-1)&1][j-2]*(k-j+2))%MOD + MOD)%MOD;
                suma2 = (suma2 - (dp2[(i-1)&1][j-2]*(k-j+2))%MOD + MOD)%MOD;
                if(i > m){
                    suma3 = (suma3 - (dp3[(i-1)&1][j-2]*(k-j+2))%MOD + MOD)%MOD;
                    suma4 = (suma4 - (dp4[(i-1)&1][j-2]*(k-j+2))%MOD + MOD)%MOD;
                }
            }
            suma1 = (suma1 + (dp1[(i-1)&1][j-1]*(k-j))%MOD)%MOD;
            suma2 = (suma2 + (dp2[(i-1)&1][j-1]*(k-j))%MOD)%MOD;
    
            dp1[i&1][j] = suma1;
            dp2[i&1][j] = (j < m) ? (suma2) : ((suma1 + suma2)%MOD);
            
           // cout << dp1[i&1][j] << ',' << dp2[i&1][j] << " ";
            aux1 = (aux1 + dp1[i&1][j])%MOD;
            aux2 = (aux2 + dp2[i&1][j])%MOD;
            
            if(i > m){
                suma3 = (suma3 + (dp3[(i-1)&1][j-1]*(k-j))%MOD)%MOD;
                suma4 = (suma4 + (dp4[(i-1)&1][j-1]*(k-j))%MOD)%MOD;
                dp3[i&1][j] = suma3;
                dp4[i&1][j] = suma4;
                aux3 = (aux3 + dp3[i&1][j])%MOD;
                aux4 = (aux4 + dp4[i&1][j])%MOD;
            }

        }
        suma1 = aux1;
        suma2 = aux2;
        //cout << endl;
        if(i>m){
            suma3 = aux3;
            suma4 = aux4;
            ini.pb(suma3);
            fin.pb(suma4);
        }
    }
    ll aux;
   // trace(aux);
    if(caso == 1) cout << total << endl;
    else if(caso == 2){
        ll veces = (suma2 * fact[k-m])%MOD;
        aux = binpow(fact[k], MOD-2);
        veces = (veces * aux)%MOD;
        total = (total - veces + MOD)%MOD;
        cout << total << endl;
    }
    else{
        ll veces = 0;
        for(int i =0 ; i <=(n-m);i++){
            veces = (veces + (ini[i]*fin[n-m-i])%MOD)%MOD;
        }
        total = (total - veces + MOD)%MOD;
        cout << total << endl;
    }
    return 0;
}

Measured memory_bytes: 3872